[librsvg] Oops, unref nodes after boxing them and using them.



commit e92a377e9ce1e183268aba4e7d7a106f94d1cff3
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 4 16:30:33 2017 -0500

    Oops, unref nodes after boxing them and using them.
    
    box_node() returns a raw pointer, and Rust can't track the lifetime of those.

 rust/src/stop.rs      |    4 +++-
 rust/src/structure.rs |    6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/rust/src/stop.rs b/rust/src/stop.rs
index 22420f0..e05218f 100644
--- a/rust/src/stop.rs
+++ b/rust/src/stop.rs
@@ -81,7 +81,9 @@ impl NodeTrait for NodeStop {
         }
 
         let inherited_state = drawing_ctx::state_new ();
-        drawing_ctx::state_reconstruct (inherited_state, box_node (node.clone ()));
+        let boxed_node = box_node (node.clone ());
+        drawing_ctx::state_reconstruct (inherited_state, boxed_node);
+        rsvg_node_unref (boxed_node);
 
         let mut color_rgba: cssparser::RGBA;
 
diff --git a/rust/src/structure.rs b/rust/src/structure.rs
index e1d939c..6f3bbbb 100644
--- a/rust/src/structure.rs
+++ b/rust/src/structure.rs
@@ -346,10 +346,12 @@ impl NodeTrait for NodeUse {
             affine.translate (nx, ny);
             drawing_ctx::set_current_state_affine (draw_ctx, affine);
 
-            let boxed_child = box_node (child.clone ());
-
             drawing_ctx::push_discrete_layer (draw_ctx);
+
+            let boxed_child = box_node (child.clone ());
             drawing_ctx::draw_node_from_stack (draw_ctx, boxed_child, 1);
+            rsvg_node_unref (boxed_child);
+
             drawing_ctx::pop_discrete_layer (draw_ctx);
         } else {
             child.with_impl (|symbol: &NodeSymbol| {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]