From 70dba7a5247f23feabef058a8e3f7d58916adb4f Mon Sep 17 00:00:00 2001 From: PeterPetrik Date: Wed, 25 Oct 2023 07:54:10 +0200 Subject: [PATCH] fix #2875 digitizing polygon undo crash --- app/maptools/recordingmaptool.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/maptools/recordingmaptool.cpp b/app/maptools/recordingmaptool.cpp index 23e40f3ea..e7d4f00f0 100644 --- a/app/maptools/recordingmaptool.cpp +++ b/app/maptools/recordingmaptool.cpp @@ -316,9 +316,14 @@ void RecordingMapTool::removePoint() mRecordedGeometry.get()->deleteVertex( current ); } - // if this was the last point in the ring and ring is interior - // we remove that ring completely - if ( r->isEmpty() && current.ring > 0 ) + // if this was the last point in the ring + // and ring is interior we remove that ring completely + // + // WARNING: + // "r" pointer may be invalid for exterior rings at this point! + // so dereference it only for interior rings + // see https://github.com/MerginMaps/input/issues/2875 + if ( current.ring > 0 && r->isEmpty() ) { QgsCurvePolygon *p = qgsgeometry_cast( poly ); // rings numerarion starts with 0