From: Sandro Santilli Date: Thu, 20 Dec 2012 18:07:13 +0000 (+0000) Subject: Fix memory leak in lwmline_locate_along X-Git-Tag: 2.1.0beta2~268 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=addeb71bd2864b63f29c74653f980e2b7a7163c9;p=postgis Fix memory leak in lwmline_locate_along git-svn-id: http://svn.osgeo.org/postgis/trunk@10878 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwlinearreferencing.c b/liblwgeom/lwlinearreferencing.c index 5ae547f99..772951648 100644 --- a/liblwgeom/lwlinearreferencing.c +++ b/liblwgeom/lwlinearreferencing.c @@ -140,15 +140,17 @@ lwmline_locate_along(const LWMLINE *lwmline, double m, double offset) for ( i = 0; i < lwmline->ngeoms; i++ ) { LWMPOINT *along = lwline_locate_along(lwmline->geoms[i], m, offset); - if ( along && ! lwgeom_is_empty((LWGEOM*)along) ) + if ( along ) { - for ( j = 0; j < along->ngeoms; j++ ) + if ( ! lwgeom_is_empty((LWGEOM*)along) ) { - lwmpoint_add_lwpoint(lwmpoint, along->geoms[j]); + for ( j = 0; j < along->ngeoms; j++ ) + { + lwmpoint_add_lwpoint(lwmpoint, along->geoms[j]); + } } /* Free the containing geometry, but leave the sub-geometries around */ - if ( along->bbox ) lwfree(along->bbox); - lwfree(along); + along->ngeoms = 0; lwmpoint_free(along); } } return lwmpoint; @@ -847,4 +849,4 @@ lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt) lwerror("This function does not accept %s geometries.", lwtype_name(lwin->type)); } return ret; -} \ No newline at end of file +}