[postgis-tickets] [PostGIS] #3405: Memory leak in lwgeom_to_points
PostGIS
trac at osgeo.org
Wed Sep 6 11:21:48 PDT 2017
#3405: Memory leak in lwgeom_to_points
----------------------+---------------------------
Reporter: dbaston | Owner: pramsey
Type: defect | Status: new
Priority: blocker | Milestone: PostGIS 2.5.0
Component: postgis | Version: trunk
Resolution: | Keywords:
----------------------+---------------------------
Comment (by pramsey):
Well, I tried extending the semantic of lwgeom_release very slightly, to
also free the underlying array containing the geoms, but unfortunately the
topology code is tied to the existing semantic. It's the only major user
of lwgeom_release, almost nothing else does. Here's what I tried
{{{
void
lwgeom_release(LWGEOM *lwgeom)
{
if ( ! lwgeom )
lwerror("lwgeom_release: someone called on 0x0");
LWDEBUGF(3, "releasing type %s", lwtype_name(lwgeom->type));
if (lwgeom_is_collection(lwgeom))
{
LWCOLLECTION *lwcol = lwgeom_as_lwcollection(lwgeom);
if (lwcol && lwcol->geoms)
lwfree(lwcol->geoms);
}
if (lwgeom_get_type(lwgeom) == POLYGONTYPE)
{
LWPOLY *lwpoly = lwgeom_as_lwpoly(lwgeom);
if (lwpoly && lwpoly->rings)
lwfree(lwpoly->rings);
}
/* Drop bounding box (always a copy) */
if ( lwgeom->bbox )
{
LWDEBUGF(3, "lwgeom_release: releasing bbox. %p",
lwgeom->bbox);
lwfree(lwgeom->bbox);
}
lwfree(lwgeom);
}
}}}
I'm just going to do the single-point patch you proposed Dan, to fix this
particular function. A library-wide fix on the semantics of
cloning/freeing/releasing is beyond scope... really at any time at all.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3405#comment:9>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list