summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Holder <thomas@thomas-holder.de>2019-10-27 06:35:34 +0000
committerThomas Holder <thomas@thomas-holder.de>2019-10-27 06:35:34 +0000
commit4b2fe2476292db84adc075d4fece8e57177a0e14 (patch)
tree03d34a9d6f7567f04d8c4a073742d6c4c6502b97 /src
parentClipboard: Fix pasting of image data on Windows (diff)
downloadinkscape-4b2fe2476292db84adc075d4fece8e57177a0e14.tar.gz
inkscape-4b2fe2476292db84adc075d4fece8e57177a0e14.zip
fix heap-use-after-free on "Unlink Clone"
Reverts part of 6e5d89bf9595
Diffstat (limited to 'src')
-rw-r--r--src/object/sp-tref.cpp2
-rw-r--r--src/object/sp-use.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/object/sp-tref.cpp b/src/object/sp-tref.cpp
index 60ce63639..a99f8686f 100644
--- a/src/object/sp-tref.cpp
+++ b/src/object/sp-tref.cpp
@@ -483,6 +483,7 @@ sp_tref_convert_to_tspan(SPObject *obj)
new_tspan->updateRepr();
// Hold onto our SPObject and repr for now.
+ sp_object_ref(tref);
Inkscape::GC::anchor(tref_repr);
// Remove ourselves, not propagating delete events to avoid a
@@ -495,6 +496,7 @@ sp_tref_convert_to_tspan(SPObject *obj)
// Establish the succession and let go of our object.
tref->setSuccessor(new_tspan);
+ sp_object_unref(tref);
}
}
////////////////////
diff --git a/src/object/sp-use.cpp b/src/object/sp-use.cpp
index c451b4e91..6fb8a206c 100644
--- a/src/object/sp-use.cpp
+++ b/src/object/sp-use.cpp
@@ -699,6 +699,7 @@ SPItem *SPUse::unlink() {
unlinked->updateRepr();
// Hold onto our SPObject and repr for now.
+ sp_object_ref(this);
Inkscape::GC::anchor(repr);
// Remove ourselves, not propagating delete events to avoid a
@@ -718,6 +719,7 @@ SPItem *SPUse::unlink() {
// Establish the succession and let go of our object.
this->setSuccessor(unlinked);
+ sp_object_unref(this);
SPItem *item = dynamic_cast<SPItem *>(unlinked);
g_assert(item != nullptr);