Skip to content

Commit

Permalink
Fix some memory leaks identified by Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 27, 2017
1 parent 7b14373 commit 799b833
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/geometry/qgsinternalgeometryengine.cpp
Expand Up @@ -58,7 +58,7 @@ QgsGeometry QgsInternalGeometryEngine::extrude( double x, double y ) const
linesToProcess << static_cast<QgsLineString*>( curve->segmentize() );
}

QgsMultiPolygonV2 *multipolygon = linesToProcess.size() > 1 ? new QgsMultiPolygonV2() : nullptr;
QScopedPointer<QgsMultiPolygonV2> multipolygon( linesToProcess.size() > 1 ? new QgsMultiPolygonV2() : nullptr );
QgsPolygonV2 *polygon = nullptr;

if ( !linesToProcess.empty() )
Expand All @@ -83,7 +83,7 @@ QgsGeometry QgsInternalGeometryEngine::extrude( double x, double y ) const
}

if ( multipolygon )
return QgsGeometry( multipolygon );
return QgsGeometry( multipolygon.take() );
else
return QgsGeometry( polygon );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -954,7 +954,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
if ( myBand != -1 )
{
Qgis::DataType myType = static_cast< Qgis::DataType >( mDataProvider->dataType( myBand ) );
QgsContrastEnhancement* myEnhancement = new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) );
QScopedPointer<QgsContrastEnhancement> myEnhancement( new QgsContrastEnhancement( static_cast< Qgis::DataType >( myType ) ) );
myEnhancement->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );

double min;
Expand All @@ -978,7 +978,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
{
myEnhancement->setMinimumValue( min );
myEnhancement->setMaximumValue( max );
myEnhancements.append( myEnhancement );
myEnhancements.append( myEnhancement.take() );
}
}
else
Expand Down
7 changes: 6 additions & 1 deletion src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -913,6 +913,8 @@ namespace QgsWfs
{
QString fcString;

QScopedPointer< QgsRectangle > transformedRect;

if ( format == QLatin1String( "GeoJSON" ) )
{
response.setHeader( "Content-Type", "application/json; charset=utf-8" );
Expand All @@ -926,7 +928,10 @@ namespace QgsWfs
try
{
if ( exportGeom.transform( transform ) == 0 )
rect = new QgsRectangle( exportGeom.boundingBox() );
{
transformedRect.reset( new QgsRectangle( exportGeom.boundingBox() ) );
rect = transformedRect.data();
}
}
catch ( QgsException &cse )
{
Expand Down

0 comments on commit 799b833

Please sign in to comment.