summaryrefslogtreecommitdiff
path: root/src/analysis/db
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-11-26 20:39:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-11-26 20:39:28 (GMT)
commit1252efcd18a845a7c2641354838c26ece3d6d873 (patch)
tree13d248454e99b76dd4c61fbd41c8c138ebb61eb7 /src/analysis/db
parent84efc00d07f9574c3867f96a3a7333b0f9d154e6 (diff)
Increased the reference counter for provided operands and updated code.
Diffstat (limited to 'src/analysis/db')
-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: