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
1=== modified file 'src/desktop.cpp'
2--- src/desktop.cpp 2017-03-14 12:48:27 +0000
3+++ src/desktop.cpp 2017-03-19 05:27:18 +0000
4@@ -1557,12 +1557,16 @@
5 layers->setDocument(doc);
6 selection->setDocument(doc);
7
8- // remove old EventLog if it exists (see also: bug #1071082)
9- if (event_log) {
10- doc->removeUndoObserver(*event_log);
11- delete event_log;
12- event_log = 0;
13- }
14+ if (event_log) {
15+ // Remove it from the replaced document. This prevents Inkscape from
16+ // crashing since we access it in the replaced document's destructor
17+ // which results in an undefined behavior. (See also: bug #1670688)
18+ if (this->doc()) {
19+ this->doc()->removeUndoObserver(*event_log);
20+ }
21+ delete event_log;
22+ event_log = 0;
23+ }
24
25 /* setup EventLog */
26 event_log = new Inkscape::EventLog(doc);