Skip to content

Commit 7e66e33

Browse files
committed
More memory leak fixes identified by Coverity
1 parent b187825 commit 7e66e33

10 files changed

+27
-7
lines changed

src/analysis/openstreetmap/qgsosmdatabase.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ void QgsOSMDatabase::exportSpatiaLiteNodes( const QString& tableName, const QStr
427427
if ( insertRes != SQLITE_DONE )
428428
{
429429
mError = QString( "Error inserting node %1 [%2]" ).arg( n.id() ).arg( insertRes );
430+
delete geom;
430431
break;
431432
}
432433

@@ -498,6 +499,7 @@ void QgsOSMDatabase::exportSpatiaLiteWays( bool closed, const QString& tableName
498499
if ( insertRes != SQLITE_DONE )
499500
{
500501
mError = QString( "Error inserting way %1 [%2]" ).arg( w.id() ).arg( insertRes );
502+
delete geom;
501503
break;
502504
}
503505

src/analysis/vector/qgsgeometryanalyzer.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,9 @@ double QgsGeometryAnalyzer::perimeterMeasure( QgsGeometry* geometry, QgsDistance
366366
{
367367
for ( jt = it->begin(); jt != it->end(); ++jt )
368368
{
369-
value = value + measure.measure( QgsGeometry::fromPolyline( *jt ) );
369+
QgsGeometry* geom = QgsGeometry::fromPolyline( *jt );
370+
value = value + measure.measure( geom );
371+
delete geom;
370372
}
371373
}
372374
}
@@ -376,7 +378,9 @@ double QgsGeometryAnalyzer::perimeterMeasure( QgsGeometry* geometry, QgsDistance
376378
QgsPolygon poly = geometry->asPolygon();
377379
for ( jt = poly.begin(); jt != poly.end(); ++jt )
378380
{
379-
value = value + measure.measure( QgsGeometry::fromPolyline( *jt ) );
381+
QgsGeometry* geom = QgsGeometry::fromPolyline( *jt );
382+
value = value + measure.measure( geom );
383+
delete geom;
380384
}
381385
}
382386
return value;

src/analysis/vector/qgszonalstatistics.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ void QgsZonalStatistics::statisticsFromPreciseIntersection( void* band, QgsGeome
362362
}
363363
delete intersectGeometry;
364364
}
365+
delete pixelRectGeometry;
366+
pixelRectGeometry = 0;
365367
}
366368
currentX += cellSizeX;
367369
}

src/app/gps/qgsgpsinformationwidget.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked()
949949
else if ( avoidIntersectionsReturn == 3 )
950950
{
951951
QMessageBox::critical( 0, tr( "Error" ), tr( "An error was reported during intersection removal" ) );
952+
delete f;
952953
connectGpsSlot();
953954
return;
954955
}
@@ -959,6 +960,7 @@ void QgsGPSInformationWidget::on_mBtnCloseFeature_clicked()
959960
QMessageBox::critical( 0, tr( "Error" ), tr( "Cannot add feature. "
960961
"Unknown WKB type. Choose a different layer and try again." ) );
961962
connectGpsSlot();
963+
delete f;
962964
return; //unknown wkbtype
963965
} // layerWKBType == QGis::WKBPolygon
964966

src/app/nodetool/qgsmaptoolnodetool.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,15 @@ void QgsMapToolNodeTool::createTopologyRubberBands( QgsVectorLayer* vlayer, cons
194194

195195
int movingPointIndex = 0;
196196
Vertexes* movingPoints = new Vertexes();
197-
Vertexes* addedPoints = new Vertexes();
197+
Vertexes* addedPoints = 0;
198198
if ( mTopologyMovingVertexes.contains( resultIt.value().snappedAtGeometry ) )
199199
{
200200
addedPoints = mTopologyMovingVertexes[ resultIt.value().snappedAtGeometry ];
201201
}
202+
else
203+
{
204+
addedPoints = new Vertexes();
205+
}
202206
if ( tVertex == -1 ) // adding first point if needed
203207
{
204208
tVertex = tVertexBackup;

src/app/qgsmaptooladdfeature.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ void QgsMapToolAddFeature::canvasMapReleaseEvent( QgsMapMouseEvent* e )
217217
{
218218
emit messageEmitted( tr( "Cannot add feature. Unknown WKB type" ), QgsMessageBar::CRITICAL );
219219
stopCapturing();
220+
delete f;
220221
return; //unknown wkbtype
221222
}
222223

@@ -236,6 +237,7 @@ void QgsMapToolAddFeature::canvasMapReleaseEvent( QgsMapMouseEvent* e )
236237
{
237238
emit messageEmitted( tr( "Cannot add feature. Unknown WKB type" ), QgsMessageBar::CRITICAL );
238239
stopCapturing();
240+
delete f;
239241
return; //unknown wkbtype
240242
}
241243

src/app/qgsmaptoolcapture.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ void QgsMapToolCapture::validateGeometry()
364364

365365
QStatusBar *sb = QgisApp::instance()->statusBar();
366366
sb->showMessage( tr( "Validation started." ) );
367+
delete g;
367368
}
368369

369370
void QgsMapToolCapture::addError( QgsGeometry::Error e )

src/app/qgsmaptooldeletepart.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ void QgsMapToolDeletePart::canvasPressEvent( QMouseEvent *e )
6666
return;
6767
}
6868

69-
QgsGeometry* geomPart;
70-
71-
geomPart = partUnderPoint( e->pos(), mPressedFid, mPressedPartNum );
69+
QgsGeometry* geomPart = partUnderPoint( e->pos(), mPressedFid, mPressedPartNum );
7270

7371
if ( mPressedFid != -1 )
7472
{
@@ -78,6 +76,7 @@ void QgsMapToolDeletePart::canvasPressEvent( QMouseEvent *e )
7876
mRubberBand->show();
7977
}
8078

79+
delete geomPart;
8180
}
8281

8382
void QgsMapToolDeletePart::canvasReleaseEvent( QMouseEvent *e )

src/app/qgsmaptooloffsetcurve.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ QgsGeometry* QgsMapToolOffsetCurve::createOriginGeometry( QgsVectorLayer* vl, co
283283
++selIt;
284284
for ( ; selIt != selectedFeatures.end(); ++selIt )
285285
{
286-
geom = geom->combine( selIt->geometry() );
286+
QgsGeometry* combined = geom->combine( selIt->geometry() );
287+
delete geom;
288+
geom = combined;
287289
}
288290

289291
//if multitype, return only the snapped to geometry

src/core/pal/problem.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ namespace pal
562562
#ifdef _VERBOSE_
563563
std::cerr << "Unknown search method..." << std::endl;
564564
#endif
565+
delete[] ok;
566+
delete[] parts;
565567
return;
566568
}
567569

0 commit comments

Comments
 (0)