Skip to content

Commit 73b9569

Browse files
committed
Fix a bunch of memory leaks
...thanks Coverity, thoverity.
1 parent f6d6c69 commit 73b9569

File tree

14 files changed

+71
-22
lines changed

14 files changed

+71
-22
lines changed

src/analysis/vector/qgstransectsample.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ QgsGeometry* QgsTransectSample::clipBufferLine( QgsGeometry* stratumGeom, QgsGeo
595595
bufferLine = QgsGeometry::fromMultiPolyline( mpl );
596596
}
597597
bufferLineClipped = bufferLine->intersection( stratumGeom );
598+
delete bufferLine;
598599

599600
if ( bufferLineClipped && bufferLineClipped->type() == QGis::Line )
600601
{
@@ -619,11 +620,13 @@ QgsGeometry* QgsTransectSample::clipBufferLine( QgsGeometry* stratumGeom, QgsGeo
619620

620621
if ( bufferLineClippedIntersectsStratum )
621622
{
623+
delete clipBaselineBuffer;
622624
return bufferLineClipped;
623625
}
624626
}
625627

626-
delete bufferLineClipped; delete clipBaselineBuffer; delete bufferLine;
628+
delete bufferLineClipped;
629+
delete clipBaselineBuffer;
627630
currentBufferDist /= 2;
628631
}
629632

src/core/qgsgeometry.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4661,7 +4661,9 @@ GEOSGeometry* QgsGeometry::linePointDifference( GEOSGeometry* GEOSsplitPoint )
46614661
else
46624662
return 0;
46634663

4664-
QgsPoint splitPoint = fromGeosGeom( GEOSsplitPoint )->asPoint();
4664+
QgsGeometry* geosPoint = fromGeosGeom( GEOSsplitPoint );
4665+
QgsPoint splitPoint = geosPoint->asPoint();
4666+
delete geosPoint;
46654667

46664668
QgsMultiPolyline lines;
46674669
QgsPolyline line;
@@ -4689,9 +4691,9 @@ GEOSGeometry* QgsGeometry::linePointDifference( GEOSGeometry* GEOSsplitPoint )
46894691
}
46904692
QgsGeometry* splitLines = fromMultiPolyline( lines );
46914693
GEOSGeometry* splitGeom = GEOSGeom_clone_r( geosinit.ctxt, splitLines->asGeos() );
4694+
delete splitLines;
46924695

46934696
return splitGeom;
4694-
46954697
}
46964698

46974699
int QgsGeometry::splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry*>& newGeometries )

src/core/qgsgml.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ void QgsGml::endElement( const XML_Char* el )
492492
}
493493
else
494494
{
495+
delete[] wkb;
495496
QgsDebugMsg( "no wkb fragments" );
496497
}
497498
}

src/core/qgsogcutils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,7 @@ QgsExpression::NodeFunction* QgsOgcUtils::nodeSpatialOperatorFromOgcFilter( QDom
16531653
else
16541654
{
16551655
errorMessage = QString( "No OGC Geometry found" );
1656+
delete gml2Args;
16561657
return NULL;
16571658
}
16581659

src/core/raster/qgscubicrasterresampler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,15 @@ void QgsCubicRasterResampler::resample( const QImage& srcImage, QImage& dstImage
263263
delete[] redMatrix;
264264
delete[] greenMatrix;
265265
delete[] blueMatrix;
266+
delete[] alphaMatrix;
266267
delete[] xDerivativeMatrixRed;
267268
delete[] xDerivativeMatrixGreen;
268269
delete[] xDerivativeMatrixBlue;
270+
delete[] xDerivativeMatrixAlpha;
269271
delete[] yDerivativeMatrixRed;
270272
delete[] yDerivativeMatrixGreen;
271273
delete[] yDerivativeMatrixBlue;
274+
delete[] yDerivativeMatrixAlpha;
272275
}
273276

274277
void QgsCubicRasterResampler::xDerivativeMatrix( int nCols, int nRows, double* matrix, const int* colorMatrix )

src/core/raster/qgsrasterresamplefilter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ QgsRasterBlock * QgsRasterResampleFilter::block( int bandNo, QgsRectangle const
167167
if ((( oversampling < 1.0 || qgsDoubleNear( oversampling, 1.0 ) ) && !mZoomedInResampler ) || ( oversampling > 1.0 && !mZoomedOutResampler ) )
168168
{
169169
QgsDebugMsg( "No oversampling." );
170+
delete outputBlock;
170171
return mInput->block( bandNumber, extent, width, height );
171172
}
172173

src/core/symbology-ng/qgsfillsymbollayerv2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,6 +2974,7 @@ QgsPointPatternFillSymbolLayer::QgsPointPatternFillSymbolLayer(): QgsImageFillSy
29742974

29752975
QgsPointPatternFillSymbolLayer::~QgsPointPatternFillSymbolLayer()
29762976
{
2977+
delete mMarkerSymbol;
29772978
}
29782979

29792980
void QgsPointPatternFillSymbolLayer::setOutputUnit( QgsSymbolV2::OutputUnit unit )

src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@
1818
#include "qgsvectorfieldsymbollayer.h"
1919
#include "qgsvectorlayer.h"
2020

21-
QgsVectorFieldSymbolLayer::QgsVectorFieldSymbolLayer(): mXAttribute( "" ), mYAttribute( "" ), mDistanceUnit( QgsSymbolV2::MM ), mScale( 1.0 ),
22-
mVectorFieldType( Cartesian ), mAngleOrientation( ClockwiseFromNorth ), mAngleUnits( Degrees ), mXIndex( -1 ), mYIndex( -1 )
21+
QgsVectorFieldSymbolLayer::QgsVectorFieldSymbolLayer()
22+
: mXAttribute( "" )
23+
, mYAttribute( "" )
24+
, mDistanceUnit( QgsSymbolV2::MM )
25+
, mScale( 1.0 )
26+
, mVectorFieldType( Cartesian )
27+
, mAngleOrientation( ClockwiseFromNorth )
28+
, mAngleUnits( Degrees )
29+
, mLineSymbol( 0 )
30+
, mXIndex( -1 )
31+
, mYIndex( -1 )
2332
{
2433
setSubSymbol( new QgsLineSymbolV2() );
2534
}
2635

2736
QgsVectorFieldSymbolLayer::~QgsVectorFieldSymbolLayer()
2837
{
38+
delete mLineSymbol;
2939
}
3040

3141
void QgsVectorFieldSymbolLayer::setOutputUnit( QgsSymbolV2::OutputUnit unit )
@@ -124,6 +134,7 @@ bool QgsVectorFieldSymbolLayer::setSubSymbol( QgsSymbolV2* symbol )
124134
{
125135
if ( symbol->type() == QgsSymbolV2::Line )
126136
{
137+
delete mLineSymbol;
127138
mLineSymbol = static_cast<QgsLineSymbolV2*>( symbol );
128139
return true;
129140
}

src/plugins/dxf2shp_converter/dxf2shpconvertergui.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,19 @@ void dxf2shpConverterGui::on_buttonBox_accepted()
9090
convtexts );
9191

9292
QgsDebugMsg( QString( "Finished getting insertions. Count: %1" ).arg( insertRetr->countInserts ) );
93+
delete dxf_inserts;
9394

9495
DL_Dxf *dxf_Main = new DL_Dxf();
9596

9697
if ( !dxf_Main->in( inf.toStdString(), parser ) )
9798
{
9899
// if file open failed
100+
delete dxf_Main;
99101
QgsDebugMsg( "Aborting: The input file could not be opened." );
100102
return;
101103
}
102104

103105
delete insertRetr;
104-
delete dxf_inserts;
105106
delete dxf_Main;
106107

107108
parser->print_shpObjects();

src/plugins/roadgraph/shortestpathwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ QgsGraph* RgShortestPathWidget::getPath( QgsPoint& p1, QgsPoint& p2 )
305305

306306
if ( shortestpathTree->findVertex( p2 ) == -1 )
307307
{
308+
delete shortestpathTree;
308309
QMessageBox::critical( this, tr( "Path not found" ), tr( "Path not found" ) );
309310
return NULL;
310311
}

0 commit comments

Comments
 (0)