]> granicus.if.org Git - postgis/commitdiff
Fix memory leak in lw_dist2d_poly_curvepoly and lw_dist2d_circstring_poly
authorSandro Santilli <strk@keybit.net>
Wed, 1 Oct 2014 13:54:05 +0000 (13:54 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 1 Oct 2014 13:54:05 +0000 (13:54 +0000)
Also clear the memory management for lwcurvepoly_construct_from_lwpoly .
Fixes #2949.

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

liblwgeom/lwcurvepoly.c
liblwgeom/measures.c

index 958ef9d0b99cbac5c91ef24875985ffd42ca11c0..5619a70c9dc1cee791746af13b8983f12b82e7a3 100644 (file)
@@ -48,7 +48,7 @@ lwcurvepoly_construct_from_lwpoly(LWPOLY *lwpoly)
        ret->nrings = lwpoly->nrings;
        ret->maxrings = lwpoly->nrings; /* Allocate room for sub-members, just in case. */
        ret->rings = lwalloc(ret->maxrings * sizeof(LWGEOM*));
-       ret->bbox = lwpoly->bbox;
+       ret->bbox = lwpoly->bbox ? gbox_clone(lwpoly->bbox) : NULL;
        for ( i = 0; i < ret->nrings; i++ )
        {
                ret->rings[i] = lwline_as_lwgeom(lwline_construct(ret->srid, NULL, ptarray_clone_deep(lwpoly->rings[i])));
index 566d0b308a3325d7c229f74b56351cd86830d369..74bcb0cd33b2184fbbbbbb9b7873b3eb486be53f 100644 (file)
@@ -905,7 +905,7 @@ lw_dist2d_poly_curvepoly(LWPOLY *poly1, LWCURVEPOLY *curvepoly2, DISTPTS *dl)
 {
        LWCURVEPOLY *curvepoly1 = lwcurvepoly_construct_from_lwpoly(poly1);
        int rv = lw_dist2d_curvepoly_curvepoly(curvepoly1, curvepoly2, dl);
-       lwfree(curvepoly1);
+       lwgeom_free((LWGEOM*)curvepoly1);
        return rv;
 }
 
@@ -914,7 +914,7 @@ lw_dist2d_circstring_poly(LWCIRCSTRING *circ, LWPOLY *poly, DISTPTS *dl)
 {
        LWCURVEPOLY *curvepoly = lwcurvepoly_construct_from_lwpoly(poly);
        int rv = lw_dist2d_line_curvepoly((LWLINE*)circ, curvepoly, dl);
-       lwfree(curvepoly);
+       lwgeom_free((LWGEOM*)curvepoly);
        return rv;
 }