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

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

NEWS
libpgcommon/gserialized_gist.c

diff --git a/NEWS b/NEWS
index 739d55c324e12992f90d7210112d4f6a0e26e940..4ee8c8db3e474c1c31683018cbbe036d9a1ef5cf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ PostGIS 2.3.8
   - #4206, Fix support for PostgreSQL 12 dev branch (Laurenz Albe)
   - #3457, Fix raster envelope shortcut in ST_Clip (Sai-bot)
   - #4223, Fix parallel/near rectangle case in geography (Paul Ramsey)
+  - #4326, Allocate enough memory in gidx_to_string (Raúl Marín)
 
 PostGIS 2.3.7
 2018/04/06
index ec2585d6a42b590f295860a5a603d0a64402ccf9..ff3a7842173366361879d6d3c7706d945f4e1cd0 100644 (file)
@@ -39,8 +39,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);