Merge lp:~wixkkomi/inkscape/fix-1670688 into lp:~inkscape.dev/inkscape/trunk

Proposed by wixkkomi
Status: Merged
Approved by: Mc
Approved revision: 15578
Merged at revision: 15608
Proposed branch: lp:~wixkkomi/inkscape/fix-1670688
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 26 lines (+10/-6)
1 file modified
src/desktop.cpp (+10/-6)
To merge this branch: bzr merge lp:~wixkkomi/inkscape/fix-1670688
Reviewer Review Type Date Requested Status
Mc Approve
Review via email: mp+320282@code.launchpad.net

Description of the change

Remove an old event log from a replaced document before allocating a new one. This prevents Inkscape from crashing since we access it in the replaced document's destructor which results in an undefined behavior. (See also: bug #1670688)

To post a comment you must log in.
Revision history for this message
wixkkomi (wixkkomi) wrote :

I resubmitted it with the newest change. For details, see comments in the
related bug.

Revision history for this message
Mc (mc...) wrote :

Looks fine

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/desktop.cpp'
--- src/desktop.cpp 2017-03-14 12:48:27 +0000
+++ src/desktop.cpp 2017-03-19 05:27:18 +0000
@@ -1557,12 +1557,16 @@
1557 layers->setDocument(doc);1557 layers->setDocument(doc);
1558 selection->setDocument(doc);1558 selection->setDocument(doc);
15591559
1560 // remove old EventLog if it exists (see also: bug #1071082)1560 if (event_log) {
1561 if (event_log) {1561 // Remove it from the replaced document. This prevents Inkscape from
1562 doc->removeUndoObserver(*event_log);1562 // crashing since we access it in the replaced document's destructor
1563 delete event_log;1563 // which results in an undefined behavior. (See also: bug #1670688)
1564 event_log = 0;1564 if (this->doc()) {
1565 }1565 this->doc()->removeUndoObserver(*event_log);
1566 }
1567 delete event_log;
1568 event_log = 0;
1569 }
15661570
1567 /* setup EventLog */1571 /* setup EventLog */
1568 event_log = new Inkscape::EventLog(doc);1572 event_log = new Inkscape::EventLog(doc);