diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-11-26 20:39:28 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-11-26 20:39:28 (GMT) |
commit | 1252efcd18a845a7c2641354838c26ece3d6d873 (patch) | |
tree | 13d248454e99b76dd4c61fbd41c8c138ebb61eb7 /src/analysis | |
parent | 84efc00d07f9574c3867f96a3a7333b0f9d154e6 (diff) |
Increased the reference counter for provided operands and updated code.
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/db/items/switcher.c | 20 | ||||
-rw-r--r-- | src/analysis/disass/links.c | 8 |
2 files changed, 24 insertions, 4 deletions
diff --git a/src/analysis/db/items/switcher.c b/src/analysis/db/items/switcher.c index 35acf5f..1863098 100644 --- a/src/analysis/db/items/switcher.c +++ b/src/analysis/db/items/switcher.c @@ -269,6 +269,7 @@ GDbSwitcher *g_db_switcher_new(GArchInstruction *instr, const GImmOperand *imm, GDbSwitcher *result; /* Instance à retourner */ size_t count; /* Nombre d'opérandes à visiter*/ size_t i; /* Boucle de parcours */ + GArchOperand *op; /* Opérande manipulé */ const mrange_t *range; /* Localisation de l'instruct° */ /* Recherche de la position de l'opérande */ @@ -278,8 +279,19 @@ GDbSwitcher *g_db_switcher_new(GArchInstruction *instr, const GImmOperand *imm, count = _g_arch_instruction_count_operands(instr); for (i = 0; i < count; i++) - if (G_ARCH_OPERAND(imm) == _g_arch_instruction_get_operand(instr, i)) + { + op = _g_arch_instruction_get_operand(instr, i); + + if (G_ARCH_OPERAND(imm) == op) + { + g_object_unref(G_OBJECT(op)); break; + } + + else + g_object_unref(G_OBJECT(op)); + + } g_arch_instruction_unlock_operands(instr); @@ -523,7 +535,7 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO if (op == NULL) { result = false; - goto exit_instr; + goto exit_without_operand; } result = G_IS_IMM_OPERAND(op); @@ -561,6 +573,10 @@ static bool g_db_switcher_run(GDbSwitcher *switcher, GLoadedBinary *binary, ImmO exit_operand: + g_object_unref(G_OBJECT(op)); + + exit_without_operand: + g_object_unref(G_OBJECT(instr)); exit_instr: diff --git a/src/analysis/disass/links.c b/src/analysis/disass/links.c index 640d266..09f8d1b 100644 --- a/src/analysis/disass/links.c +++ b/src/analysis/disass/links.c @@ -237,7 +237,7 @@ static void convert_immediate_into_target(GArchInstruction *instr, size_t index, ciit_done: - ; + g_object_unref(G_OBJECT(op)); } @@ -280,7 +280,7 @@ void establish_links_for_instruction(GArchInstruction *instr, GBinFormat *format convert_immediate_into_target(instr, i, format); op = _g_arch_instruction_get_operand(instr, i); - if (!G_IS_TARGET_OPERAND(op)) continue; + if (!G_IS_TARGET_OPERAND(op)) goto next_op; g_target_operand_get_addr(G_TARGET_OPERAND(op), &addr); @@ -295,6 +295,10 @@ void establish_links_for_instruction(GArchInstruction *instr, GBinFormat *format } + next_op: + + g_object_unref(G_OBJECT(op)); + } g_arch_instruction_unlock_operands(instr); |