From 71015d23d051229db4b86d4e81dd887826c95d79 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 22 Aug 2022 11:15:14 +0200 Subject: [PATCH] App: fix possible dangling pointer in Document::removeObject() --- src/App/Document.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 7276901e45..d5af1f0449 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -4215,6 +4215,10 @@ void Document::removeObject(const char* sName) } } + // In case the object gets deleted the pointer must be nullified + if (tobedestroyed) { + tobedestroyed->pcNameInDocument = nullptr; + } d->objectMap.erase(pos); }