From: Sandro Santilli Date: Wed, 1 Oct 2014 13:54:05 +0000 (+0000) Subject: Fix memory leak in lw_dist2d_poly_curvepoly and lw_dist2d_circstring_poly X-Git-Tag: 2.2.0rc1~820 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9ca6dfe39f2663b1172c9d1898256676b0dc44d;p=postgis Fix memory leak in lw_dist2d_poly_curvepoly and lw_dist2d_circstring_poly 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 --- diff --git a/liblwgeom/lwcurvepoly.c b/liblwgeom/lwcurvepoly.c index 958ef9d0b..5619a70c9 100644 --- a/liblwgeom/lwcurvepoly.c +++ b/liblwgeom/lwcurvepoly.c @@ -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]))); diff --git a/liblwgeom/measures.c b/liblwgeom/measures.c index 566d0b308..74bcb0cd3 100644 --- a/liblwgeom/measures.c +++ b/liblwgeom/measures.c @@ -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; }