From: Paul Ramsey Date: Mon, 29 Jun 2015 17:10:12 +0000 (+0000) Subject: Remove memory leak X-Git-Tag: 2.2.0rc1~292 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1497259359469ffa4765da1653d664a975ffd9a;p=postgis Remove memory leak git-svn-id: http://svn.osgeo.org/postgis/trunk@13746 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwpoly.c b/liblwgeom/lwpoly.c index 2c21e3783..ef9f1b6fd 100644 --- a/liblwgeom/lwpoly.c +++ b/liblwgeom/lwpoly.c @@ -356,7 +356,10 @@ LWPOLY* lwpoly_simplify(const LWPOLY *ipoly, double dist, int preserve_collapsed LWDEBUGF(2, "%s: simplifying polygon with %d rings", __func__, ipoly->nrings); if ( lwpoly_is_empty(ipoly) ) + { + lwpoly_free(opoly); return NULL; + } for ( i = 0; i < ipoly->nrings; i++ ) { @@ -383,14 +386,20 @@ LWPOLY* lwpoly_simplify(const LWPOLY *ipoly, double dist, int preserve_collapsed /* Add ring to simplified polygon */ if( lwpoly_add_ring(opoly, opts) == LW_FAILURE ) + { + lwpoly_free(opoly); return NULL; + } } LWDEBUGF(3, "simplified polygon with %d rings", ipoly->nrings); opoly->type = ipoly->type; if( lwpoly_is_empty(opoly) ) + { + lwpoly_free(opoly); return NULL; + } return opoly; }