]> granicus.if.org Git - postgis/commitdiff
Fix memory leak in lwmline_locate_along
authorSandro Santilli <strk@keybit.net>
Thu, 20 Dec 2012 18:07:13 +0000 (18:07 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 20 Dec 2012 18:07:13 +0000 (18:07 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10878 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwlinearreferencing.c

index 5ae547f99cf9602ef634b4e5dcd2bfffdbdb1a07..772951648519c8aea99012e70392ece10f54c314 100644 (file)
@@ -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
+}