[PostGIS] #6012: Memory leak in function lwcircstring_from_lwpointarray

PostGIS trac at osgeo.org
Thu Nov 6 00:57:30 PST 2025


#6012: Memory leak in function lwcircstring_from_lwpointarray
-----------------------+---------------------------
  Reporter:  ezimanyi  |      Owner:  pramsey
      Type:  defect    |     Status:  new
  Priority:  medium    |  Milestone:  PostGIS 3.6.1
 Component:  postgis   |    Version:  3.5.x
Resolution:            |   Keywords:
-----------------------+---------------------------
Comment (by mschoema):

 I believe the issue is actually in lwcircstring_from_lwpointarray and
 comes from how the three functions interact. Essentially,
 lwcircstring_from_lwpointarray first allocates memory to write the points
 in, then calls ptarray_construct_reference_data, then calls
 lwcircstring_construct. But this means that at the end of the function,
 the resulting LWCIRCSTRING does not own its own pointarry. This will thus
 cause memory leaks when trying to free the circstring, because no-one else
 owns this pointarray. I believe lwcircstring_from_lwpointarray should
 either call ptarray_construct_copy_data (but that's an unnecessary memory
 allocation) or change the readonly flag of its pointarray before
 returning.
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6012#comment:2>
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