summaryrefslogtreecommitdiff
path: root/plugins/elf
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 /plugins/elf
parentff187d24b7441e88e1f0361d59b0f6f55851791f (diff)
Fixed a huge number of memory leaks.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/format.c2
-rw-r--r--plugins/elf/loading.c2
-rw-r--r--plugins/elf/strings.c8
-rw-r--r--plugins/elf/symbols.c9
4 files changed, 20 insertions, 1 deletions
diff --git a/plugins/elf/format.c b/plugins/elf/format.c
index d6bdc5e..08472e4 100644
--- a/plugins/elf/format.c
+++ b/plugins/elf/format.c
@@ -541,6 +541,8 @@ static bool g_elf_format_get_main_address(GElfFormat *format, vmpa2t *addr)
copy_vmpa(addr, get_mrange_addr(range));
+ g_object_unref(G_OBJECT(symbol));
+
}
return result;
diff --git a/plugins/elf/loading.c b/plugins/elf/loading.c
index eb992b9..73e75f0 100644
--- a/plugins/elf/loading.c
+++ b/plugins/elf/loading.c
@@ -496,6 +496,8 @@ static void g_elf_loading_process(GElfLoading *loading, GtkStatusStack *status)
{
ret = loading->callback_1(loading, format, symbol);
+ g_object_unref(G_OBJECT(symbol));
+
if (!ret)
{
log_variadic_message(LMT_ERROR, _("Error while applying ELF relocation %zu!"), processed);
diff --git a/plugins/elf/strings.c b/plugins/elf/strings.c
index f6be4a8..fe37a0d 100644
--- a/plugins/elf/strings.c
+++ b/plugins/elf/strings.c
@@ -345,6 +345,12 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys
g_raw_instruction_mark_as_string(G_RAW_INSTRUCTION(instr), true);
+ /**
+ * Comme g_preload_info_add_instruction() peut consommer l'instruction
+ * et qu'on réutilise cette dernière ensuite avec g_arch_instruction_get_range()...
+ */
+ g_object_ref(G_OBJECT(instr));
+
inserted = g_preload_info_add_instruction(base->info, instr);
result |= inserted;
@@ -373,6 +379,8 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys
}
+ g_object_unref(G_OBJECT(instr));
+
/* Conclusion */
skip_first:
diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c
index b6f05f6..5ddc99c 100644
--- a/plugins/elf/symbols.c
+++ b/plugins/elf/symbols.c
@@ -195,7 +195,10 @@ static void register_elf_entry_point(GElfFormat *format, virt_t vaddr, phys_t le
/* Comptabilisation en tant que symbole */
if (g_binary_format_find_symbol_at(G_BIN_FORMAT(format), &addr, &symbol))
+ {
+ g_object_unref(G_OBJECT(symbol));
g_object_unref(G_OBJECT(routine));
+ }
else
{
@@ -552,11 +555,13 @@ static bool do_elf_symbol_loading(GElfLoading *loading, GElfFormat *format, bool
{
g_binary_symbol_set_status(symbol, status);
+ /*
if (new != NULL)
{
g_object_ref(G_OBJECT(symbol));
*new = symbol;
}
+ */
g_binary_format_add_symbol(base, symbol);
@@ -749,6 +754,8 @@ static bool do_elf_global_symbol_loading(GElfLoading *loading, GElfFormat *forma
result = do_elf_symbol_loading(loading, format, false, iter, &symbol);
+ //g_clear_object(&symbol);
+
return result;
}
@@ -1048,7 +1055,7 @@ static bool load_elf_relocations(GElfFormat *format, const elf_phdr *dynamic, el
{
result &= g_elf_loading_get_status(loadings[i]);
- g_object_ref(G_OBJECT(loadings[i]));
+ g_object_unref(G_OBJECT(loadings[i]));
}