From 6c6c743daf3c1de391c9ff2586a7df60bd7b7759 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 19 Dec 2018 00:02:24 +0100
Subject: Used the reference counter when providing basic block lists.

---
 plugins/pychrysalide/analysis/routine.c | 2 ++
 src/analysis/disass/rank.c              | 2 ++
 src/analysis/routine.c                  | 8 +++++++-
 src/gtkext/gtkgraphdisplay.c            | 2 ++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/plugins/pychrysalide/analysis/routine.c b/plugins/pychrysalide/analysis/routine.c
index e57b919..1f245ae 100644
--- a/plugins/pychrysalide/analysis/routine.c
+++ b/plugins/pychrysalide/analysis/routine.c
@@ -543,6 +543,8 @@ static PyObject *py_binary_routine_get_basic_blocks(PyObject *self, void *closur
 
     result = pygobject_new(G_OBJECT(blocks));
 
+    g_object_unref(G_OBJECT(blocks));
+
     return result;
 
 }
diff --git a/src/analysis/disass/rank.c b/src/analysis/disass/rank.c
index b4a8f92..b6eb4c5 100644
--- a/src/analysis/disass/rank.c
+++ b/src/analysis/disass/rank.c
@@ -130,4 +130,6 @@ void rank_routine_blocks(GBinRoutine *routine)
 
     g_object_unref(G_OBJECT(start));
 
+    g_object_unref(G_OBJECT(blocks));
+
 }
diff --git a/src/analysis/routine.c b/src/analysis/routine.c
index fa68ecd..4116044 100644
--- a/src/analysis/routine.c
+++ b/src/analysis/routine.c
@@ -710,7 +710,13 @@ size_t g_binary_routine_get_var_index_from_offset(const GBinRoutine *routine, si
 
 GBlockList *g_binary_routine_get_basic_blocks(const GBinRoutine *routine)
 {
-    return routine->blocks;
+    GBlockList *result;                     /* Instance de liste à renvoyer*/
+
+    result = routine->blocks;
+
+    g_object_ref(G_OBJECT(result));
+
+    return result;
 
 }
 
diff --git a/src/gtkext/gtkgraphdisplay.c b/src/gtkext/gtkgraphdisplay.c
index 7721a44..955f540 100644
--- a/src/gtkext/gtkgraphdisplay.c
+++ b/src/gtkext/gtkgraphdisplay.c
@@ -672,6 +672,8 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, cons
         display->cluster = bootstrap_graph_cluster(GTK_DISPLAY_PANEL(display)->binary,
                                                    list, display->highlighted);
 
+        g_object_unref(G_OBJECT(list));
+
         g_graph_cluster_place(display->cluster, display);
 
         /**
-- 
cgit v0.11.2-87-g4458