]> 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:06:54 +0000 (09:06 +0000)
committerRaúl Marín Rodríguez <rmrodriguez@carto.com>
Thu, 15 Nov 2018 09:06:54 +0000 (09:06 +0000)
References #4236

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

NEWS
libpgcommon/gserialized_gist.c

diff --git a/NEWS b/NEWS
index 6e16057b4292a5f85380306da91db77353220295..c2917c5c83bc8985e28e4242ffc6b4b36c40237f 100644 (file)
--- 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
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);