Skip to content

Commit

Permalink
Fix leak in QgsGeometry make valid
Browse files Browse the repository at this point in the history
Also swap some GEOS methods to managed versions
  • Loading branch information
nyalldawson committed Feb 7, 2017
1 parent c80d84e commit 91d2e4f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/geometry/qgsgeometrymakevalid.cpp
Expand Up @@ -897,6 +897,7 @@ QgsAbstractGeometry* _qgis_lwgeom_make_valid( const QgsAbstractGeometry& lwgeom_


// try to convert to GEOS, if impossible, clean that up first // try to convert to GEOS, if impossible, clean that up first
// otherwise (adding only duplicates of existing points) // otherwise (adding only duplicates of existing points)
GEOSContextHandle_t handle = QgsGeos::getGEOSHandler();


GEOSGeometry* geosgeom = QgsGeos::asGeos( &lwgeom_in ); GEOSGeometry* geosgeom = QgsGeos::asGeos( &lwgeom_in );
if ( ! geosgeom ) if ( ! geosgeom )
Expand Down Expand Up @@ -927,11 +928,12 @@ QgsAbstractGeometry* _qgis_lwgeom_make_valid( const QgsAbstractGeometry& lwgeom_
} }


GEOSGeometry* geosout = LWGEOM_GEOS_makeValid( geosgeom, errorMessage ); GEOSGeometry* geosout = LWGEOM_GEOS_makeValid( geosgeom, errorMessage );
GEOSGeom_destroy( geosgeom ); GEOSGeom_destroy_r( handle, geosgeom );
if ( !geosout ) if ( !geosout )
return NULL; return NULL;


QgsAbstractGeometry* lwgeom_out = QgsGeos::fromGeos( geosout ); QgsAbstractGeometry* lwgeom_out = QgsGeos::fromGeos( geosout );
GEOSGeom_destroy_r( handle, geosout );
if ( !lwgeom_out ) if ( !lwgeom_out )
return NULL; return NULL;


Expand Down

0 comments on commit 91d2e4f

Please sign in to comment.