Skip to content

Commit

Permalink
App: [skip ci] fix possible segmentation fault when performing a tran…
Browse files Browse the repository at this point in the history
…saction after an undo
  • Loading branch information
wwmayer committed Oct 23, 2020
1 parent 3415401 commit cda1205
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/App/Document.cpp
Expand Up @@ -178,6 +178,7 @@ struct DocumentP
bool rollback;
bool undoing; ///< document in the middle of undo or redo
bool committing;
bool opentransaction;
std::bitset<32> StatusBits;
int iUndoMode;
unsigned int UndoMemSize;
Expand Down Expand Up @@ -205,6 +206,7 @@ struct DocumentP
rollback = false;
undoing = false;
committing = false;
opentransaction = false;
StatusBits.set((size_t)Document::Closable, true);
StatusBits.set((size_t)Document::KeepTrailingDigits, true);
StatusBits.set((size_t)Document::Restoring, false);
Expand Down Expand Up @@ -1101,6 +1103,14 @@ int Document::_openTransaction(const char* name, int id)
}

if (d->iUndoMode) {
// Avoid recursive calls that is possible while
// clearing the redo transactions and will cause
// a double deletion of some transaction and thus
// a segmentation fault
if (d->opentransaction)
return 0;
Base::FlagToggler<> flag(d->opentransaction);

if(id && mUndoMap.find(id)!=mUndoMap.end())
throw Base::RuntimeError("invalid transaction id");
if (d->activeUndoTransaction)
Expand Down

0 comments on commit cda1205

Please sign in to comment.