]> granicus.if.org Git - postgis/commitdiff
SVG empty geometries gives invalid memory alloc (#1038)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 24 Jan 2012 22:23:53 +0000 (22:23 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 24 Jan 2012 22:23:53 +0000 (22:23 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8920 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwout_svg.c
regress/tickets.sql
regress/tickets_expected

index 651f91984ceecb4d079741e8f7dda42b088c8c6e..387a5afe97ee74981d4036e201572c356621b094 100644 (file)
@@ -44,6 +44,14 @@ lwgeom_to_svg(const LWGEOM *geom, int precision, int relative)
 {
        char *ret = NULL;
        int type = geom->type;
+
+       /* Empty string for empties */
+       if( lwgeom_is_empty(geom) )
+       {
+               ret = lwalloc(1);
+               ret[0] = '\0';
+               return ret;
+       }
        
        switch (type)
        {
index 3349b1a60cd19a0b5dc78f0245ccc95d1ad717a2..2dd4d00c09064d8f10333b8a2807ecc33f243e33 100644 (file)
@@ -569,6 +569,8 @@ insert into spatial_ref_sys (srid, proj4text) values (500001,NULL);
 insert into spatial_ref_sys (srid, proj4text) values (500002, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs');
 select '#1150', st_astext(st_transform('SRID=500002;POINT(0 0)',500001));
 
+-- #1038
+select '#1038', ST_AsSVG('POLYGON EMPTY'::geometry);
 
 -- Clean up
 DELETE FROM spatial_ref_sys;
index 94f530d8999b519f2992a39780398db3c662dba6..da97cda371692f2fe1670a44901dd1d929ae9141 100644 (file)
@@ -185,3 +185,4 @@ ERROR:  MultiSurface cannot contain MultiPoint element
 #852.2|2|t|t
 #1489|MULTIPOINT EMPTY|0|MULTILINESTRING EMPTY|0|MULTIPOLYGON EMPTY|0|GEOMETRYCOLLECTION EMPTY|0
 ERROR:  AddToPROJ4SRSCache: couldn't parse proj4 string: '': (null)
+#1038|