]> granicus.if.org Git - postgis/commitdiff
Fix non NULL terminated string in ST_AsSVG with GEOMETRYCOLLECTION EMPTY, cf #409...
authorOlivier Courtin <olivier.courtin@camptocamp.com>
Sat, 6 Feb 2010 10:48:23 +0000 (10:48 +0000)
committerOlivier Courtin <olivier.courtin@camptocamp.com>
Sat, 6 Feb 2010 10:48:23 +0000 (10:48 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/1.4@5209 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_svg.c
regress/svg.sql
regress/svg_expected

index e0de9d59a7b3a719da1db897b1cbe474b05f2748..900e1c6fc52b5389159bff6e1a5a37231cc0f8f6 100644 (file)
@@ -475,6 +475,8 @@ assvg_collection_size(LWGEOM_INSPECTED *insp, bool relative, int precision)
        if ( i ) /* We have some geometries, so add space for delimiters. */ 
                size += sizeof(";") * --i;
 
+       if (size == 0) size++; /* EMPTY GEOMETRYCOLLECTION */
+
        return size;
 }
 
@@ -486,6 +488,9 @@ assvg_collection_buf(LWGEOM_INSPECTED *insp, char *output, bool relative, int pr
        LWGEOM_INSPECTED *subinsp;
        uchar *subgeom;
 
+       /* EMPTY GEOMETRYCOLLECTION */
+       if (insp->ngeometries == 0) *ptr = '\0';
+
        for (i=0; i<insp->ngeometries; i++)
        {
                if (i) ptr += sprintf(ptr, ";");
index 7e8a691f0649e02bd21389f53d52f973ccc10ed9..42bc76a1e1a82d5703954297961502161d8bc618 100755 (executable)
@@ -147,6 +147,10 @@ SELECT '3D_02', ST_AsSVG(GeomFromEWKT('SRID=4326;POINT(1 1 1)'), 0);
 SELECT '3D_03', ST_AsSVG(GeomFromEWKT('SRID=4326;LINESTRING(1 1 1, 2 2 2, 3 3 3, 4 4 4)'), 0);
 SELECT '3D_04', ST_AsSVG(GeomFromEWKT('SRID=4326;POLYGON((1 1 1, 2 2 2, 3 3 3, 4 4 4, 5 5 5, 5 0 0, 1 1 1))'), 0);
 
+
+-- EMPTY GEOMETRYCOLLECTION  #409
+SELECT '#409', ST_AsSVG(GeomFromEWKT('GEOMETRYCOLLECTION EMPTY'));
+
 --
 -- Delete inserted spatial data
 --
index d3f008403b87d3332eb6542fa94cb830a0c34991..7bf12d4edf5ac99aa1a4534d2debbf478bfd54e3 100644 (file)
@@ -41,3 +41,4 @@ ERROR:  ST_AsSVG: 'MultiSurface' geometry type not supported.
 3D_02|cx="1" cy="-1"
 3D_03|M 1 -1 L 2 -2 3 -3 4 -4
 3D_04|M 1 -1 L 2 -2 3 -3 4 -4 5 -5 5 0 Z
+#409|