Opened 6 years ago

Closed 6 years ago

#4429 closed defect (fixed)

PROJ6: lwgeom_transform_from_str leaks PJs

Reported by: Algunenano Owned by: Algunenano
Priority: high Milestone: PostGIS 3.0.0
Component: postgis Version: master
Keywords: Cc:

Description

The current implementation of lwgeom_transform_from_str is leaking PJ and might leak pj_out on error:

int
lwgeom_transform_from_str(LWGEOM *geom, const char* instr, const char* outstr)
{
	PJ *pj = proj_create_crs_to_crs(NULL, instr, outstr, NULL);
	if (!pj)
	{
		PJ *pj_in = proj_create(NULL, instr);
		PJ *pj_out = proj_create(NULL, outstr);
		if (!pj_in)
		{
			lwerror("could not parse proj string '%s'", instr);
<<<<<<<<<<<<<< pj_out might be leaked
		}
		if (!pj_out)
		{
			proj_destroy(pj_in);
			lwerror("could not parse proj string '%s'", outstr);
		}
<<<<<<<<<<<<<< pj_out is definetely leaked
		return LW_FAILURE;
	}

	return lwgeom_transform(geom, pj);
<<<<<<<<<<<<<<<<<<<< pj is leaked
}

I'm planning to fix this as part of the process of reviewing the slowness issue with PROJ6, just making a note here.

Change History (1)

comment:1 by algunenano, 6 years ago

Resolution: fixed
Status: assignedclosed

In 17539:

lwgeom_transform_from_str: Avoid leaking resources under PROJ6+

Closes #4429

Note: See TracTickets for help on using tickets.