From 5b9cfb2d32e909242345baca23eec240517f87f1 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 e79862cd99..882f2d4f07 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -4225,6 +4225,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); }