From: Raúl Marín Rodríguez Date: Thu, 15 Nov 2018 09:06:54 +0000 (+0000) Subject: Allocate enough memory in gidx_to_string X-Git-Tag: 2.5.1~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=482ac43169b5d821f1fd2c712b248852fbb37e9b;p=postgis Allocate enough memory in gidx_to_string References #4236 git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17018 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index 6e16057b4..c2917c5c8 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ XXXX/XX/XX - Schema qualify more functions for raster (Regina Obe) - #4216, Revert non-sliced box access (Paul Ramsey) - #2767, Documentation for AddRasterConstraint optional parameters (Sunveer Singh) + - #4326, Allocate enough memory in gidx_to_string (Raúl Marín) PostGIS 2.5.0 diff --git a/libpgcommon/gserialized_gist.c b/libpgcommon/gserialized_gist.c index e153d420a..d2e7738fa 100644 --- a/libpgcommon/gserialized_gist.c +++ b/libpgcommon/gserialized_gist.c @@ -35,8 +35,13 @@ char* gidx_to_string(GIDX *a) if ( a == NULL ) return pstrdup(""); - - str = (char*)palloc(128); /* 15*2*4+8==128 */ + /* 4 (GIDX_MAX_DIM) * + * 2 (MAX & MIN) * + * 20 (Max representation (e.g. -3.40282346639e+38) [19] + space) + * = 4*2*20 = 160 + * + 9 [ 'GIDX(' = 5, ',' = 1, ' )' = 2 + '\0' = 1] + */ + str = (char *)palloc(169); rv = str; ndims = GIDX_NDIMS(a);