summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-02-05 22:03:38 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-02-05 22:03:38 (GMT)
commit17f591f2230ac66394467d5e5eefe71cb259637d (patch)
tree1664e994b2904e5e9009027fc57749a11667365b /src/format
parentff187d24b7441e88e1f0361d59b0f6f55851791f (diff)
Fixed a huge number of memory leaks.
Diffstat (limited to 'src/format')
-rw-r--r--src/format/debuggable.c2
-rw-r--r--src/format/executable.c3
-rw-r--r--src/format/format.c26
-rw-r--r--src/format/strsym.c2
4 files changed, 23 insertions, 10 deletions
diff --git a/src/format/debuggable.c b/src/format/debuggable.c
index 571163b..7020c38 100644
--- a/src/format/debuggable.c
+++ b/src/format/debuggable.c
@@ -125,6 +125,4 @@ void g_debuggable_format_attach_executable(GDbgFormat *format, GExeFormat *execu
{
format->executable = executable;
- g_object_ref(G_OBJECT(executable));
-
}
diff --git a/src/format/executable.c b/src/format/executable.c
index cda2e3a..00d685c 100644
--- a/src/format/executable.c
+++ b/src/format/executable.c
@@ -181,8 +181,7 @@ void g_exe_format_add_debug_info(GExeFormat *format, GDbgFormat *info)
else
log_variadic_message(LMT_INFO, _("Found debug information: %s"), desc);
- format->debugs = (GDbgFormat **)realloc(format->debugs,
- ++format->debugs_count * sizeof(GDbgFormat *));
+ format->debugs = realloc(format->debugs, ++format->debugs_count * sizeof(GDbgFormat *));
format->debugs[format->debugs_count - 1] = info;
diff --git a/src/format/format.c b/src/format/format.c
index cd71a21..ab4864f 100644
--- a/src/format/format.c
+++ b/src/format/format.c
@@ -156,10 +156,19 @@ static void g_binary_format_init(GBinFormat *format)
static void g_binary_format_dispose(GBinFormat *format)
{
- g_clear_object(&format->demangler);
+ size_t i; /* Boucle de parcours */
+
+ g_clear_object(&format->content);
+
+ g_rw_lock_clear(&format->pt_lock);
g_clear_object(&format->info);
+ g_clear_object(&format->demangler);
+
+ for (i = 0; i < format->sym_count; i++)
+ g_clear_object(&format->symbols[i]);
+
g_rw_lock_clear(&format->syms_lock);
g_mutex_clear(&format->error_mutex);
@@ -185,6 +194,15 @@ static void g_binary_format_finalize(GBinFormat *format)
{
size_t i; /* Boucle de parcours */
+ if (format->entry_points != NULL)
+ free(format->entry_points);
+
+ if (format->extra_points != NULL)
+ free(format->extra_points);
+
+ if (format->symbols != NULL)
+ free(format->symbols);
+
if (format->errors != NULL)
{
for (i = 0; i < format->error_count; i++)
@@ -386,8 +404,7 @@ void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, bool ent
if (entry)
{
- format->entry_points = (virt_t *)realloc(format->entry_points,
- ++format->ep_count * sizeof(virt_t));
+ format->entry_points = realloc(format->entry_points, ++format->ep_count * sizeof(virt_t));
format->entry_points[format->ep_count - 1] = pt;
@@ -398,8 +415,7 @@ void g_binary_format_register_code_point(GBinFormat *format, virt_t pt, bool ent
{
format->xp_allocated += EXTRA_POINT_BLOCK;
- format->extra_points = (virt_t *)realloc(format->extra_points,
- format->xp_allocated * sizeof(virt_t));
+ format->extra_points = realloc(format->extra_points, format->xp_allocated * sizeof(virt_t));
}
diff --git a/src/format/strsym.c b/src/format/strsym.c
index 6feb8a1..4e8479e 100644
--- a/src/format/strsym.c
+++ b/src/format/strsym.c
@@ -193,7 +193,7 @@ static void g_string_symbol_feeder_interface_init(GProxyFeederInterface *iface)
static void g_string_symbol_dispose(GStrSymbol *symbol)
{
if (symbol->has_content)
- g_object_unref(G_OBJECT(symbol->content));
+ g_clear_object(&symbol->content);
G_OBJECT_CLASS(g_string_symbol_parent_class)->dispose(G_OBJECT(symbol));