From cf9ea46a796000f0252bb7d80c0ac0fb170e156a Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Tue, 18 Dec 2012 23:26:56 +0000
Subject: Fixed a bug when the binary loading fails.

git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@306 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
---
 ChangeLog                    | 12 ++++++++++++
 src/analysis/binaries/file.c |  8 +-------
 src/analysis/binary.c        | 22 ++++++----------------
 src/format/format.c          | 13 -------------
 4 files changed, 19 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 070bd51..bc095d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+12-12-19  Cyrille Bagard <nocbos@gmail.com>
+
+	* src/analysis/binaries/file.c:
+	Improve the 'finalize' method.
+
+	* src/analysis/binary.c:
+	Improve the cleaning process of loaded binaries and fix a bug when
+	loading fails.
+
+	* src/format/format.c:
+	Remove debug output.
+
 12-12-18  Cyrille Bagard <nocbos@gmail.com>
 
 	* configure.ac:
diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c
index 46307fb..9c43ed5 100644
--- a/src/analysis/binaries/file.c
+++ b/src/analysis/binaries/file.c
@@ -133,15 +133,9 @@ static void g_file_binary_init(GFileBinary *binary)
 
 static void g_file_binary_finalize(GFileBinary *binary)
 {
-    gpointer obj_class;                     /* Classe parente              */
-
     free(binary->filename);
 
-    /* On passe le relai */
-
-    obj_class = g_type_class_peek_parent(G_FILE_BINARY_GET_CLASS(binary));
-
-    G_OBJECT_CLASS(obj_class)->finalize(G_OBJECT(binary));
+    G_OBJECT_CLASS(g_file_binary_parent_class)->finalize(G_OBJECT(binary));
 
 }
 
diff --git a/src/analysis/binary.c b/src/analysis/binary.c
index ecf9c79..61f826a 100644
--- a/src/analysis/binary.c
+++ b/src/analysis/binary.c
@@ -146,18 +146,14 @@ static void g_loaded_binary_init(GLoadedBinary *binary)
 
 static void g_loaded_binary_dispose(GLoadedBinary *binary)
 {
-    gpointer obj_class;                     /* Classe parente              */
-
-    g_object_unref(G_OBJECT(binary->format));
-    g_object_unref(G_OBJECT(binary->proc));
+    if (binary->format != NULL)
+        g_object_unref(G_OBJECT(binary->format));
+    if (binary->proc != NULL)
+        g_object_unref(G_OBJECT(binary->proc));
 
     /* TODO... */
 
-    /* On passe le relai */
-
-    obj_class = g_type_class_peek_parent(G_FILE_BINARY_GET_CLASS(binary));
-
-    G_OBJECT_CLASS(obj_class)->dispose(G_OBJECT(binary));
+    G_OBJECT_CLASS(g_loaded_binary_parent_class)->dispose(G_OBJECT(binary));
 
 }
 
@@ -176,15 +172,9 @@ static void g_loaded_binary_dispose(GLoadedBinary *binary)
 
 static void g_loaded_binary_finalize(GLoadedBinary *binary)
 {
-    gpointer obj_class;                     /* Classe parente              */
-
     /* TODO */
 
-    /* On passe le relai */
-
-    obj_class = g_type_class_peek_parent(G_FILE_BINARY_GET_CLASS(binary));
-
-    G_OBJECT_CLASS(obj_class)->finalize(G_OBJECT(binary));
+    G_OBJECT_CLASS(g_loaded_binary_parent_class)->finalize(G_OBJECT(binary));
 
 }
 
diff --git a/src/format/format.c b/src/format/format.c
index f1ea4d4..c7d95c4 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -510,10 +510,6 @@ GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, of
 
     result = NULL;
 
-    printf("analysing... %s\n", filename);
-
-
-
     tmp = strdup(filename);
 
     pglist = get_all_plugins_for_action(PGA_FORMAT_MATCHER, &pgcount);
@@ -545,9 +541,6 @@ GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, of
     if (tmp == NULL)
         free(tmp);
 
-
-
-
     for (i = 0; i < FID_COUNT && result == NULL; i++)
         if (_formats[i].type == type && _formats[i].match(type, *content, *length))
         {
@@ -557,12 +550,6 @@ GBinFormat *load_new_format(FormatType type, char *filename, bin_t **content, of
 
         }
 
-
-
-    printf("FINAL FORMAT :: %p\n", result);
-
-    //exit(0);
-
     return result;
 
 }
-- 
cgit v0.11.2-87-g4458