]> granicus.if.org Git - postgis/commitdiff
Fix short allocation of edge to curves store (#2425)
authorSandro Santilli <strk@keybit.net>
Tue, 13 Aug 2013 07:27:23 +0000 (07:27 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 13 Aug 2013 07:27:23 +0000 (07:27 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11789 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_ptarray.c
liblwgeom/lwsegmentize.c

index aec35740f638f038ceeeec52d771e1d155cb2646..369720f0ebeabb105519c86eef298699696e2e83 100644 (file)
@@ -405,7 +405,17 @@ static void test_ptarray_desegmentize()
 //     printf("%s\n", str);
        lwfree(str);            
        
-  // See http://trac.osgeo.org/postgis/ticket/2412
+       // See http://trac.osgeo.org/postgis/ticket/2425 
+       // and http://trac.osgeo.org/postgis/ticket/2420 
+       in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10,0 0)");
+       out = lwgeom_desegmentize(in);
+       str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
+       CU_ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10,0 0)");
+       lwgeom_free(in);
+       lwgeom_free(out);
+       lwfree(str);    
+
+       // See http://trac.osgeo.org/postgis/ticket/2412
        in = lwgeom_from_text("LINESTRING(0 0, 1 1)");
        out = lwgeom_desegmentize(in);
        str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
@@ -414,6 +424,7 @@ static void test_ptarray_desegmentize()
        lwgeom_free(in);
        lwgeom_free(out);
        lwfree(str);            
+
 }
 
 static void test_ptarray_contains_point() 
index 991cb1f6b353a55a4a58bf0585ae53f9d6b8d073..1db038e20dfa5a0358598af96c6ab311cdda00b0 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "liblwgeom_internal.h"
 
-//#define POSTGIS_DEBUG_LEVEL 4
+/* #define POSTGIS_DEBUG_LEVEL 4 */
 
 #include "lwgeom_log.h"
 
@@ -614,8 +614,8 @@ pta_desegmentize(POINTARRAY *points, int type, int srid)
        
        /* Allocate our result array of vertices that are part of arcs */
        num_edges = points->npoints - 1;
-       edges_in_arcs = lwalloc(num_edges);
-       memset(edges_in_arcs, 0, num_edges);
+       edges_in_arcs = lwalloc(num_edges + 1);
+       memset(edges_in_arcs, 0, num_edges + 1);
        
        /* We make a candidate arc of the first two edges, */
        /* And then see if the next edge follows it */