Skip to content
Permalink
Browse files

Fix some memory leaks identified by Coverity

  • Loading branch information
nyalldawson committed Jan 27, 2017
1 parent 7b14373 commit 799b833caea4c599e15030a5c282caff8110d579
@@ -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() )
@@ -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 );
}
@@ -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;
@@ -978,7 +978,7 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
{
myEnhancement->setMinimumValue( min );
myEnhancement->setMaximumValue( max );
myEnhancements.append( myEnhancement );
myEnhancements.append( myEnhancement.take() );
}
}
else
@@ -913,6 +913,8 @@ namespace QgsWfs
{
QString fcString;

QScopedPointer< QgsRectangle > transformedRect;

if ( format == QLatin1String( "GeoJSON" ) )
{
response.setHeader( "Content-Type", "application/json; charset=utf-8" );
@@ -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 )
{

0 comments on commit 799b833

Please sign in to comment.
You can’t perform that action at this time.