pgLatLon
changeset 79:16787a19a325
Do not return CSTRING to static memory
Avoids wrong pfree under certain circumstances
(e.g. array_agg on empty EBOX or ECLUSTER).
Avoids wrong pfree under certain circumstances
(e.g. array_agg on empty EBOX or ECLUSTER).
| author | jbe |
|---|---|
| date | Thu Oct 23 10:16:01 2025 +0200 (34 hours ago) |
| parents | 4eb23fd90088 |
| children | b9cdc74a90db |
| files | latlon-v0010.c |
line diff
1.1 --- a/latlon-v0010.c Wed Jan 01 22:28:46 2025 +0100 1.2 +++ b/latlon-v0010.c Thu Oct 23 10:16:01 2025 +0200 1.3 @@ -2243,7 +2243,7 @@ 1.4 char lon_min_str[PGL_NUMBUFLEN]; 1.5 char lon_max_str[PGL_NUMBUFLEN]; 1.6 /* return string "empty" if box is set to be empty */ 1.7 - if (box->lat_min > box->lat_max) PG_RETURN_CSTRING("empty"); 1.8 + if (box->lat_min > box->lat_max) PG_RETURN_CSTRING(pstrdup("empty")); 1.9 /* use boundaries exceeding W180 or E180 if 180th meridian is enclosed */ 1.10 /* (required since pgl_box_in orders the longitude boundaries) */ 1.11 if (lon_min > lon_max) { 1.12 @@ -2291,7 +2291,7 @@ 1.13 /* free detoasted cluster (if copy) */ 1.14 PG_FREE_IF_COPY(cluster, 0); 1.15 /* return static result */ 1.16 - PG_RETURN_CSTRING("empty"); 1.17 + PG_RETURN_CSTRING(pstrdup("empty")); 1.18 } 1.19 /* allocate array of array of strings */ 1.20 strings = palloc(cluster->nentries * sizeof(char **));