]> granicus.if.org Git - postgis/commitdiff
Allocate enough memory in gidx_to_string
authorRaúl Marín Rodríguez <rmrodriguez@carto.com>
Thu, 15 Nov 2018 09:08:17 +0000 (09:08 +0000)
committerRaúl Marín Rodríguez <rmrodriguez@carto.com>
Thu, 15 Nov 2018 09:08:17 +0000 (09:08 +0000)
Close #4236

git-svn-id: http://svn.osgeo.org/postgis/trunk@17019 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
libpgcommon/gserialized_gist.c

diff --git a/NEWS b/NEWS
index 79b676b0d2ea22ace24e6cd787f627964998c4e3..350d1f40f86c1a34eb4c6073535374cc740c01a8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,7 @@ PostGIS 3.0.0
   - #4155, Support for GEOMETRYCOLLECTION, POLYGON, TIN, TRIANGLE in
            ST_LocateBetween and ST_LocateBetweenElevations (Darafei Praliaskouski)
   - #2767, Documentation for AddRasterConstraint optional parameters (Sunveer Singh)
+  - #4326, Allocate enough memory in gidx_to_string (Raúl Marín)
 
 PostGIS 2.5.0
 2018/09/23
index e153d420a21cde07197221e8ec8f927974f4f14a..d2e7738fa73ad5cc233bee2ff69260d365d66dd5 100644 (file)
@@ -35,8 +35,13 @@ char* gidx_to_string(GIDX *a)
 
        if ( a == NULL )
                return pstrdup("<NULLPTR>");
-
-       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);