App: [skip ci] AddressSanitizer: heap-use-after-free

In Document::removeObject() do not access object after it has been possibly deleted
This commit is contained in:
wmayer
2021-02-23 14:30:00 +01:00
parent eed7357674
commit 7cf4d4b01e

View File

@@ -4157,6 +4157,11 @@ void Document::removeObject(const char* sName)
TipName.setValue("");
}
// remove the ID before possibly deleting the object
d->objectIdMap.erase(pos->second->_Id);
// Unset the bit to be on the safe side
pos->second->setStatus(ObjectStatus::Remove, false);
// do no transactions if we do a rollback!
std::unique_ptr<DocumentObject> tobedestroyed;
if (!d->rollback) {
@@ -4180,8 +4185,6 @@ void Document::removeObject(const char* sName)
}
}
pos->second->setStatus(ObjectStatus::Remove, false); // Unset the bit to be on the safe side
d->objectIdMap.erase(pos->second->_Id);
d->objectMap.erase(pos);
}