summaryrefslogtreecommitdiff
path: root/src/analysis/db/items/switcher.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/items/switcher.c')
-rw-r--r--src/analysis/db/items/switcher.c20
1 files changed, 18 insertions, 2 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: