From e5d58e1f70405012fd8fbe8d61937f92fa3583a9 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Thu, 3 Nov 2016 15:01:38 +0100
Subject: Counted references for each provided binary format.

---
 ChangeLog                           | 37 +++++++++++++++++++++++++
 plugins/androhelpers/androhelpers.c | 11 ++++++--
 plugins/androhelpers/params.c       |  1 +
 plugins/androhelpers/switch.c       |  1 +
 plugins/androhelpers/try_n_catch.c  |  9 ++++--
 plugins/libcsem/exit.c              |  4 +--
 plugins/pychrysa/analysis/binary.c  |  2 +-
 plugins/ropgadgets/select.c         |  1 -
 plugins/stackvars/stackvars.c       |  2 ++
 src/analysis/binary.c               |  8 ++++--
 src/analysis/decomp/decompiler.c    |  5 ++--
 src/analysis/disass/area.c          |  6 ++--
 src/analysis/disass/disassembler.c  | 55 ++++++++++++++++++++++++++++++++++++-
 src/analysis/disass/fetch.c         |  2 +-
 src/analysis/project.c              |  2 ++
 src/gtkext/gtkbinarystrip.c         |  4 +++
 src/gtkext/gtkbufferview.c          |  7 ++++-
 src/gtkext/gtkgraphview.c           |  1 +
 src/gtkext/gtkstatusstack.c         |  4 +--
 src/gui/dialogs/gotox.c             |  4 +++
 src/gui/dialogs/shellcode.c         |  2 ++
 src/gui/panels/bookmarks.c          |  9 ------
 src/gui/panels/strings.c            |  3 +-
 src/gui/panels/symbols.c            |  4 +++
 src/gui/tb/source.c                 |  3 ++
 src/panels/breaks.c                 |  3 ++
 26 files changed, 156 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a219511..fea9acd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,42 @@
 16-11-03  Cyrille Bagard <nocbos@gmail.com>
 
+	* plugins/androhelpers/androhelpers.c:
+	* plugins/androhelpers/params.c:
+	* plugins/androhelpers/switch.c:
+	* plugins/androhelpers/try_n_catch.c:
+	* plugins/libcsem/exit.c:
+	* plugins/pychrysa/analysis/binary.c:
+	* plugins/ropgadgets/select.c:
+	* plugins/stackvars/stackvars.c:
+	Update code.
+
+	* src/analysis/binary.c:
+	Count references for each provided binary format.
+
+	* src/analysis/decomp/decompiler.c:
+	* src/analysis/disass/area.c:
+	* src/analysis/disass/disassembler.c:
+	* src/analysis/disass/fetch.c:
+	* src/analysis/project.c:
+	* src/gtkext/gtkbinarystrip.c:
+	* src/gtkext/gtkbufferview.c:
+	* src/gtkext/gtkgraphview.c:
+	* src/gtkext/gtkstatusstack.c:
+	* src/gui/dialogs/gotox.c:
+	* src/gui/dialogs/shellcode.c:
+	Update code.
+
+	* src/gui/panels/bookmarks.c:
+	Remove useless code.
+
+	* src/gui/panels/strings.c:
+	* src/gui/panels/symbols.c:
+	* src/gui/tb/source.c:
+	* src/panels/breaks.c:
+	Update code.
+
+16-11-03  Cyrille Bagard <nocbos@gmail.com>
+
 	* plugins/pychrysa/format/format.c:
 	Extend a little bit the Python bindings.
 
diff --git a/plugins/androhelpers/androhelpers.c b/plugins/androhelpers/androhelpers.c
index 1ba9640..a95c925 100644
--- a/plugins/androhelpers/androhelpers.c
+++ b/plugins/androhelpers/androhelpers.c
@@ -95,11 +95,16 @@ PluginAction get_plugin_action(const GPluginModule *plugin)
 bool execute_action_on_binary(GPluginModule *plugin, GLoadedBinary *binary, PluginAction action)
 {
     bool result;                            /* Bilan à retourner           */
+    GExeFormat *format;                     /* Format associé au binaire   */
 
-    if (!G_IS_DEX_FORMAT(g_loaded_binary_get_format(binary)))
-        return false;
+    format = g_loaded_binary_get_format(binary);
+
+    result = G_IS_DEX_FORMAT(format);
 
-    result = true;
+    g_object_unref(G_OBJECT(format));
+
+    if (!result)
+        return false;
 
     if (action == PGA_BINARY_DISASSEMBLED)
         result &= replace_parameters(binary);
diff --git a/plugins/androhelpers/params.c b/plugins/androhelpers/params.c
index ee580b6..c9b1109 100644
--- a/plugins/androhelpers/params.c
+++ b/plugins/androhelpers/params.c
@@ -218,6 +218,7 @@ bool replace_parameters(GLoadedBinary *binary)
     }
 
     g_object_unref(G_OBJECT(proc));
+    g_object_unref(G_OBJECT(format));
 
     return true;
 
diff --git a/plugins/androhelpers/switch.c b/plugins/androhelpers/switch.c
index d976e56..43b6ae1 100644
--- a/plugins/androhelpers/switch.c
+++ b/plugins/androhelpers/switch.c
@@ -422,6 +422,7 @@ bool extract_switch_info(GLoadedBinary *binary, bool link)
     }
 
     g_object_unref(G_OBJECT(proc));
+    g_object_unref(G_OBJECT(format));
 
     return true;
 
diff --git a/plugins/androhelpers/try_n_catch.c b/plugins/androhelpers/try_n_catch.c
index 780fa59..28f7061 100644
--- a/plugins/androhelpers/try_n_catch.c
+++ b/plugins/androhelpers/try_n_catch.c
@@ -237,8 +237,8 @@ static void mark_exception_handlers(const GLoadedBinary *binary, uleb128_t size,
 static caught_exception **build_all_destinations_list(const GLoadedBinary *binary, const GBinRoutine *routine, const encoded_catch_handler_list *hlist, size_t **count)
 {
     caught_exception **result;              /* Liste de listes à retourner */
-    GDexFormat *format;                     /* Format du binaire chargé    */
     vmpa_t start;                           /* Début du code de la routine */
+    GDexFormat *format;                     /* Format du binaire chargé    */
     GArchProcessor *proc;                   /* Processeur de l'architecture*/
     GArchInstruction *instrs;               /* Instructions Dalvik         */
     uleb128_t i;                            /* Boucle de parcours #1       */
@@ -248,10 +248,10 @@ static caught_exception **build_all_destinations_list(const GLoadedBinary *binar
     caught_exception *excep;                /* Raccourci confortable       */
     GDataType *type;                        /* Type de l'exception         */
 
-    format = G_DEX_FORMAT(g_loaded_binary_get_format(binary));
-
     start = g_binary_routine_get_address(routine);
 
+    format = G_DEX_FORMAT(g_loaded_binary_get_format(binary));
+
     proc = g_loaded_binary_get_processor(binary);
     instrs = g_arch_processor_get_disassembled_instructions(proc);
     instrs = g_arch_instruction_find_by_address(instrs, start, true);
@@ -312,6 +312,7 @@ static caught_exception **build_all_destinations_list(const GLoadedBinary *binar
     }
 
     g_object_unref(G_OBJECT(proc));
+    g_object_unref(G_OBJECT(format));
 
     return result;
 
@@ -448,6 +449,8 @@ bool process_exception_handlers(GLoadedBinary *binary, bool link)
 
     }
 
+    g_object_unref(G_OBJECT(format));
+
     return true;
 
 }
diff --git a/plugins/libcsem/exit.c b/plugins/libcsem/exit.c
index 9db8286..b5545b9 100644
--- a/plugins/libcsem/exit.c
+++ b/plugins/libcsem/exit.c
@@ -88,9 +88,7 @@ static void mark_one_kind_of_exit_as_return(const GLoadedBinary *binary, const c
 
  mokoear_exit:
 
-    //g_object_unref(G_OBJECT(format));
-
-    ;
+    g_object_unref(G_OBJECT(format));
 
 }
 
diff --git a/plugins/pychrysa/analysis/binary.c b/plugins/pychrysa/analysis/binary.c
index b01d0b3..32e4a71 100644
--- a/plugins/pychrysa/analysis/binary.c
+++ b/plugins/pychrysa/analysis/binary.c
@@ -183,7 +183,7 @@ static PyObject *py_loaded_binary_get_format(PyObject *self, void *closure)
 
     result = pygobject_new(G_OBJECT(format));
 
-    //g_object_unref(G_OBJECT(format));
+    g_object_unref(G_OBJECT(format));
 
     return result;
 
diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c
index 8aa6021..8878839 100644
--- a/plugins/ropgadgets/select.c
+++ b/plugins/ropgadgets/select.c
@@ -1287,7 +1287,6 @@ static GBinFormat *load_internal_format_for_rop_gadgets(GObject *ref)
 
     push_status_printing_of_rop_search_step(ref, "format", _("already loaded"), true);
 
-    g_object_ref(G_OBJECT(result));
     g_object_unref(G_OBJECT(binary));
 
     return result;
diff --git a/plugins/stackvars/stackvars.c b/plugins/stackvars/stackvars.c
index 49c831f..f4c43be 100644
--- a/plugins/stackvars/stackvars.c
+++ b/plugins/stackvars/stackvars.c
@@ -115,6 +115,8 @@ G_MODULE_EXPORT bool execute_action_on_binary(GLoadedBinary *binary, PluginActio
     for (i = 0; i < routines_count; i++)
         result |= replace_stack_vars_in_routine(routines[i], lines);
 
+    g_object_unref(G_OBJECT(format));
+
     return result;
 
 }
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index e466c33..2563355 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -1461,9 +1461,13 @@ bool g_loaded_binary_attach_debug_info(GLoadedBinary *binary, GBinContent *conte
 
 GExeFormat *g_loaded_binary_get_format(const GLoadedBinary *binary)
 {
-    /* TODO : inc ref ! */
+    GExeFormat *result;                     /* Instance à retourner        */
 
-    return binary->format;
+    result = binary->format;
+
+    g_object_ref(G_OBJECT(result));
+
+    return result;
 
 }
 
diff --git a/src/analysis/decomp/decompiler.c b/src/analysis/decomp/decompiler.c
index bca45e1..04ae7c4 100644
--- a/src/analysis/decomp/decompiler.c
+++ b/src/analysis/decomp/decompiler.c
@@ -202,8 +202,7 @@ static void prepare_all_routines_for_decomp(const GLoadedBinary *binary, const c
 
     }
 
-
-
+    g_object_unref(G_OBJECT(format));
 
 }
 
@@ -237,8 +236,10 @@ GCodeBuffer *decompile_all_from_file(const GLoadedBinary *binary, const char *fi
 
 
     format = g_loaded_binary_get_format(binary);
+
     g_binary_format_decompile(G_BIN_FORMAT(format), result, filename);
 
+    g_object_unref(G_OBJECT(format));
 
     return result;
 
diff --git a/src/analysis/disass/area.c b/src/analysis/disass/area.c
index fed1cc9..52ba933 100644
--- a/src/analysis/disass/area.c
+++ b/src/analysis/disass/area.c
@@ -143,9 +143,9 @@ static void fini_mem_area(mem_area *area)
     phys_t len;                             /* Etendue du parcours total   */
     phys_t i;                               /* Boucle de parcours          */
 
-    //g_object_unref(area->format);   /* FIXME */
+    g_object_unref(area->format);
     g_object_unref(area->content);
-    //g_object_unref(area->proc);   /* FIXME */
+    g_object_unref(area->proc);
 
     delete_bit_field(area->processed);
 
@@ -896,7 +896,7 @@ mem_area *compute_memory_areas(const GLoadedBinary *binary, phys_t bin_length, s
     if (exe_ranges != NULL)
         free(exe_ranges);
 
-    /// FIXME g_object_unref(G_OBJECT(format));
+    g_object_unref(G_OBJECT(format));
 
     return result;
 
diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c
index f036be6..8a19f9d 100644
--- a/src/analysis/disass/disassembler.c
+++ b/src/analysis/disass/disassembler.c
@@ -75,6 +75,12 @@ static void g_delayed_disassembly_class_init(GDelayedDisassemblyClass *);
 /* Initialise une tâche de désassemblage différé. */
 static void g_delayed_disassembly_init(GDelayedDisassembly *);
 
+/* Supprime toutes les références externes. */
+static void g_delayed_disassembly_dispose(GDelayedDisassembly *);
+
+/* Procède à la libération totale de la mémoire. */
+static void g_delayed_disassembly_finalize(GDelayedDisassembly *);
+
 /* Crée une tâche de désassemblage différé. */
 static GDelayedDisassembly *g_delayed_disassembly_new(GLoadedBinary *, GArchInstruction **, GCodeBuffer *);
 
@@ -120,8 +126,14 @@ G_DEFINE_TYPE(GDelayedDisassembly, g_delayed_disassembly, G_TYPE_DELAYED_WORK);
 
 static void g_delayed_disassembly_class_init(GDelayedDisassemblyClass *klass)
 {
+    GObjectClass *object;                   /* Autre version de la classe  */
     GDelayedWorkClass *work;                /* Version en classe parente   */
 
+    object = G_OBJECT_CLASS(klass);
+
+    object->dispose = (GObjectFinalizeFunc/* ! */)g_delayed_disassembly_dispose;
+    object->finalize = (GObjectFinalizeFunc)g_delayed_disassembly_finalize;
+
     work = G_DELAYED_WORK_CLASS(klass);
 
     work->run = (run_task_fc)g_delayed_disassembly_process;
@@ -149,6 +161,46 @@ static void g_delayed_disassembly_init(GDelayedDisassembly *disass)
 
 /******************************************************************************
 *                                                                             *
+*  Paramètres  : binary = instance d'objet GLib à traiter.                    *
+*                                                                             *
+*  Description : Supprime toutes les références externes.                     *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static void g_delayed_disassembly_dispose(GDelayedDisassembly *disass)
+{
+    g_object_unref(G_OBJECT(disass->format));
+
+    G_OBJECT_CLASS(g_delayed_disassembly_parent_class)->dispose(G_OBJECT(disass));
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : disass = instance d'objet GLib à traiter.                    *
+*                                                                             *
+*  Description : Procède à la libération totale de la mémoire.                *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+static void g_delayed_disassembly_finalize(GDelayedDisassembly *disass)
+{
+    G_OBJECT_CLASS(g_delayed_disassembly_parent_class)->finalize(G_OBJECT(disass));
+
+}
+
+
+/******************************************************************************
+*                                                                             *
 *  Paramètres  : binary = binaire chargé en attente des résultats.            *
 *                format = format du binaire représenté.                       *
 *                instrs = emplacement pour la liste d'instructions.           *
@@ -338,7 +390,6 @@ static void g_delayed_disassembly_process(GDelayedDisassembly *disass, GtkStatus
 
 
 
-    //format = G_BIN_FORMAT(g_loaded_binary_get_format(binary));
     proc = g_loaded_binary_get_processor(disass->binary);
     ctx = g_arch_processor_get_context(proc);
 
@@ -700,6 +751,8 @@ void disassemble_binary(GLoadedBinary *binary, GArchInstruction **instrs, GCodeB
     checksum = g_binary_content_get_checksum(content);
     g_object_unref(G_OBJECT(content));
 
+    g_object_unref(G_OBJECT(format));
+
     build_disass_prologue(*buffer, g_binary_content_describe(content, true), checksum);
 
     disass = g_delayed_disassembly_new(binary, instrs, *buffer);
diff --git a/src/analysis/disass/fetch.c b/src/analysis/disass/fetch.c
index aab7258..55a23b6 100644
--- a/src/analysis/disass/fetch.c
+++ b/src/analysis/disass/fetch.c
@@ -471,7 +471,7 @@ GArchInstruction *disassemble_binary_content(const GLoadedBinary *binary, GProcC
 
     /* Libérations finales */
 
-    //g_object_unref(G_OBJECT(template.format));
+    g_object_unref(G_OBJECT(template.format));
 
     release_mem_areas(template.areas, template.count);
 
diff --git a/src/analysis/project.c b/src/analysis/project.c
index a3c004d..7b4f621 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -631,6 +631,8 @@ void g_study_project_attach_binary(GStudyProject *project, GLoadedBinary *binary
 
         }
 
+        g_object_unref(G_OBJECT(format));
+
         return FALSE;
 
     }
diff --git a/src/gtkext/gtkbinarystrip.c b/src/gtkext/gtkbinarystrip.c
index 1cf2450..fff6a78 100644
--- a/src/gtkext/gtkbinarystrip.c
+++ b/src/gtkext/gtkbinarystrip.c
@@ -233,6 +233,7 @@ static void gtk_binary_strip_size_allocate(GtkWidget *widget, GtkAllocation *all
         strip->cursor_pos = 0;
 
     g_object_unref(G_OBJECT(layer));
+    g_object_unref(G_OBJECT(format));
 
 }
 
@@ -290,6 +291,7 @@ static gboolean gtk_binary_strip_button_release(GtkWidget *widget, GdkEventButto
     }
 
     g_object_unref(G_OBJECT(layer));
+    g_object_unref(G_OBJECT(format));
 
     return FALSE;
 
@@ -338,6 +340,7 @@ static gboolean gtk_binary_strip_draw(GtkWidget *widget, cairo_t *cr)
     g_portion_layer_draw(layer, context, cr, &full);
 
     g_object_unref(G_OBJECT(layer));
+    g_object_unref(G_OBJECT(format));
 
     /* Dessin de la position */
 
@@ -412,6 +415,7 @@ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *widget, gint x, gint y
         result = g_portion_layer_query_tooltip(layer, x, y, &area, tooltip);
 
         g_object_unref(G_OBJECT(layer));
+        g_object_unref(G_OBJECT(format));
 
     }
     else result = FALSE;
diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c
index caa7eb0..1f4399a 100644
--- a/src/gtkext/gtkbufferview.c
+++ b/src/gtkext/gtkbufferview.c
@@ -558,6 +558,7 @@ static gboolean gtk_buffer_view_key_press(GtkWidget *widget, GdkEventKey *event)
 static gboolean gtk_buffer_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard, GtkTooltip *tooltip)
 {
     gboolean result;                        /* Bilan à retourner           */
+    GBinFormat *format;                     /* Format du fichier binaire   */
     GtkBufferView *view;                    /* Autre version du composant  */
     gint real_x;                            /* Abscisse absolue réelle     */
     gint real_y;                            /* Ordonnée absolue réelle     */
@@ -565,7 +566,6 @@ static gboolean gtk_buffer_view_query_tooltip(GtkWidget *widget, gint x, gint y,
     GObject *creator;                       /* Créateur à l'orgine du seg. */
     virt_t virt;                            /* Adresse virtuelle           */
     vmpa2t addr;                            /* Adresse de destination      */
-    GBinFormat *format;                     /* Format du fichier binaire   */
     GBinSymbol *target_sym;                 /* Symbole présent à l'adresse */
     GBinSymbol *next_sym;                   /* Symbole suivant l'adresse   */
     GCodeBuffer *buffer;                    /* Tampon où lire les lignes   */
@@ -581,6 +581,8 @@ static gboolean gtk_buffer_view_query_tooltip(GtkWidget *widget, gint x, gint y,
 
     result = FALSE;
 
+    format = NULL;
+
     view = GTK_BUFFER_VIEW(widget);
 
     /* Récupération de la destination pointée */
@@ -692,6 +694,9 @@ static gboolean gtk_buffer_view_query_tooltip(GtkWidget *widget, gint x, gint y,
         g_object_unref(G_OBJECT(line));
     */
 
+    if (format != NULL)
+        g_object_unref(G_OBJECT(format));
+
     return result;
 
 }
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c
index 3136cf4..fc307a2 100644
--- a/src/gtkext/gtkgraphview.c
+++ b/src/gtkext/gtkgraphview.c
@@ -782,6 +782,7 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, const vmpa2t
 
         change_editor_items_current_view_content(GTK_VIEW_PANEL(view));
 
+        g_object_unref(G_OBJECT(format));
 
     }
 
diff --git a/src/gtkext/gtkstatusstack.c b/src/gtkext/gtkstatusstack.c
index 930fa4a..ac1716e 100644
--- a/src/gtkext/gtkstatusstack.c
+++ b/src/gtkext/gtkstatusstack.c
@@ -609,9 +609,7 @@ void gtk_status_stack_update_current_instruction(GtkStatusStack *stack, const GL
 
  gssuci_useless:
 
-    //g_object_unref(G_OBJECT(format));
-
-    ;
+    g_object_unref(G_OBJECT(format));
 
 }
 
diff --git a/src/gui/dialogs/gotox.c b/src/gui/dialogs/gotox.c
index 340da5c..02f1a02 100644
--- a/src/gui/dialogs/gotox.c
+++ b/src/gui/dialogs/gotox.c
@@ -245,6 +245,8 @@ GtkWidget *create_gotox_dialog_for_entry_points(GtkWindow *parent, GLoadedBinary
 
     }
 
+    g_object_unref(G_OBJECT(format));
+
     g_object_unref(G_OBJECT(store));
 
     gtk_dialog_set_response_sensitive(GTK_DIALOG(result), GTK_RESPONSE_OK, has_entry_points);
@@ -402,6 +404,8 @@ static void add_new_location_to_list(GtkTreeStore *store, GLoadedBinary *binary,
 
         }
 
+        g_object_unref(G_OBJECT(format));
+
     }
 
     /* Image de représentation */
diff --git a/src/gui/dialogs/shellcode.c b/src/gui/dialogs/shellcode.c
index faf3bdf..5c1a33c 100644
--- a/src/gui/dialogs/shellcode.c
+++ b/src/gui/dialogs/shellcode.c
@@ -222,6 +222,8 @@ static void export_assistant_close(GtkAssistant *assistant, GObject *ref)
     */
     gtk_widget_destroy(GTK_WIDGET(assistant));
 
+    g_object_unref(G_OBJECT(format));
+
 }
 
 
diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c
index eaa2168..893c1bd 100644
--- a/src/gui/panels/bookmarks.c
+++ b/src/gui/panels/bookmarks.c
@@ -573,7 +573,6 @@ static void on_collection_content_changed(GDbCollection *collec, DBAction action
     GtkTreeStore *store;                    /* Modèle de gestion           */
 
 
-    GExeFormat *format;                     /* Format du fichier binaire   */
     GArchProcessor *proc;                   /* Architecture du binaire     */
     MemoryDataSize msize;                   /* Taille par défaut           */
 
@@ -590,18 +589,10 @@ static void on_collection_content_changed(GDbCollection *collec, DBAction action
     {
         store = GTK_TREE_STORE(gtk_tree_view_get_model(panel->treeview));
 
-        format = g_loaded_binary_get_format(panel->binary);
-
-
         proc = g_loaded_binary_get_processor(panel->binary);
         msize = g_arch_processor_get_memory_size(proc);
         g_object_unref(G_OBJECT(proc));
 
-
-
-
-
-
         addr = g_db_bookmark_get_address(bookmark);
 
         vmpa2_phys_to_string(addr, msize, phys, NULL);
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index 5d25b09..a651fff 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -560,8 +560,9 @@ static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBin
 
     }
 
-    g_object_unref(G_OBJECT(layer));
     g_object_unref(G_OBJECT(content));
+    g_object_unref(G_OBJECT(layer));
+    g_object_unref(G_OBJECT(format));
 
 }
 
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index ac2a703..4fffe35 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -706,6 +706,8 @@ static void reload_symbols_for_new_list_view(GSymbolsPanel *panel)
 
     }
 
+    g_object_unref(G_OBJECT(format));
+
 }
 
 
@@ -918,6 +920,8 @@ static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel)
 
     }
 
+    g_object_unref(G_OBJECT(format));
+
 }
 
 
diff --git a/src/gui/tb/source.c b/src/gui/tb/source.c
index 0685368..02ed643 100644
--- a/src/gui/tb/source.c
+++ b/src/gui/tb/source.c
@@ -260,6 +260,9 @@ static void update_source_item_binary(GEditorItem *item, GLoadedBinary *binary)
     g_signal_handlers_unblock_by_func(combo, G_CALLBACK(change_selected_source), item);
 
     //gtk_combo_box_set_active(combo, defsrc);
+
+    g_object_unref(G_OBJECT(format));
+
 #endif
 }
 
diff --git a/src/panels/breaks.c b/src/panels/breaks.c
index 6b11f1e..875f995 100644
--- a/src/panels/breaks.c
+++ b/src/panels/breaks.c
@@ -343,6 +343,9 @@ static void refresh_breaks_panel_on_bp_added(GBreakGroup *group, GBreakPoint *po
 
     /* Pour le reste... */
     refresh_breaks_panel_on_bp_changed(group, point, panel);
+
+    g_object_unref(G_OBJECT(format));
+
 #endif
 }
 
-- 
cgit v0.11.2-87-g4458