# HG changeset patch # User jbe # Date 1761207361 -7200 # Node ID 16787a19a325d8c04f3ef7bca25b20ad918aaf49 # Parent 4eb23fd90088faefa669cc2ebbb4cb59e562f23e Do not return CSTRING to static memory Avoids wrong pfree under certain circumstances (e.g. array_agg on empty EBOX or ECLUSTER). diff -r 4eb23fd90088 -r 16787a19a325 latlon-v0010.c --- a/latlon-v0010.c Wed Jan 01 22:28:46 2025 +0100 +++ b/latlon-v0010.c Thu Oct 23 10:16:01 2025 +0200 @@ -2243,7 +2243,7 @@ char lon_min_str[PGL_NUMBUFLEN]; char lon_max_str[PGL_NUMBUFLEN]; /* return string "empty" if box is set to be empty */ - if (box->lat_min > box->lat_max) PG_RETURN_CSTRING("empty"); + if (box->lat_min > box->lat_max) PG_RETURN_CSTRING(pstrdup("empty")); /* use boundaries exceeding W180 or E180 if 180th meridian is enclosed */ /* (required since pgl_box_in orders the longitude boundaries) */ if (lon_min > lon_max) { @@ -2291,7 +2291,7 @@ /* free detoasted cluster (if copy) */ PG_FREE_IF_COPY(cluster, 0); /* return static result */ - PG_RETURN_CSTRING("empty"); + PG_RETURN_CSTRING(pstrdup("empty")); } /* allocate array of array of strings */ strings = palloc(cluster->nentries * sizeof(char **));