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/arch | |
parent | 84efc00d07f9574c3867f96a3a7333b0f9d154e6 (diff) |
Increased the reference counter for provided operands and updated code.
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/arm/v7/fetch.c | 14 | ||||
-rw-r--r-- | src/arch/arm/v7/link.c | 4 | ||||
-rw-r--r-- | src/arch/arm/v7/post.c | 2 | ||||
-rw-r--r-- | src/arch/instruction.c | 13 | ||||
-rw-r--r-- | src/arch/link.c | 14 | ||||
-rw-r--r-- | src/arch/post.c | 2 | ||||
-rw-r--r-- | src/arch/raw.c | 6 |
7 files changed, 47 insertions, 8 deletions
diff --git a/src/arch/arm/v7/fetch.c b/src/arch/arm/v7/fetch.c index a1ddd3e..dee9aa2 100644 --- a/src/arch/arm/v7/fetch.c +++ b/src/arch/arm/v7/fetch.c @@ -94,6 +94,8 @@ void help_fetching_with_instruction_b_with_orig(GArchInstruction *instr, GArchPr else assert(0); + g_object_unref(G_OBJECT(op)); + target = pc + offset; //g_armv7_context_define_encoding(context, target, iset); @@ -157,6 +159,8 @@ void help_fetching_with_instruction_bl_with_orig(GArchInstruction *instr, GArchP else assert(0); + g_object_unref(G_OBJECT(op)); + target = pc + offset; //g_armv7_context_define_encoding(context, target, iset); @@ -210,6 +214,8 @@ void help_fetching_with_instruction_blx_with_dest(GArchInstruction *instr, GArch else assert(0); + g_object_unref(G_OBJECT(op)); + target = pc + offset; //g_armv7_context_define_encoding(context, target, iset); @@ -284,7 +290,7 @@ void help_fetching_with_instruction_bx_with_orig(GArchInstruction *instr, GArchP hfwibwo_no_pc: - ; + g_object_unref(G_OBJECT(op)); } @@ -329,6 +335,8 @@ void help_fetching_with_instruction_cb_n_z(GArchInstruction *instr, GArchProcess else assert(0); + g_object_unref(G_OBJECT(op)); + target = pc + offset; //g_armv7_context_define_encoding(context, target, AV7IS_THUMB); @@ -405,6 +413,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst if (!ret) { assert(0); + g_object_unref(G_OBJECT(op)); g_arch_instruction_unlock_operands(instr); return; } @@ -416,6 +425,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst if (!g_exe_format_translate_offset_into_vmpa(format, val_offset, &loaded_addr)) { assert(0); + g_object_unref(G_OBJECT(op)); g_arch_instruction_unlock_operands(instr); return; } @@ -433,6 +443,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst if (!ret) { + g_object_unref(G_OBJECT(op)); g_arch_instruction_unlock_operands(instr); return; } @@ -484,6 +495,7 @@ void help_fetching_with_instruction_ldr_literal_with_orig(GArchInstruction *inst new = g_imm_operand_new_from_value(MDS_32_BITS_UNSIGNED, target); _g_arch_instruction_replace_operand(instr, op, new); + g_object_unref(G_OBJECT(op)); g_arch_instruction_unlock_operands(instr); diff --git a/src/arch/arm/v7/link.c b/src/arch/arm/v7/link.c index 63fb3ae..68cde7b 100644 --- a/src/arch/arm/v7/link.c +++ b/src/arch/arm/v7/link.c @@ -65,6 +65,8 @@ void handle_armv7_conditional_branch_from_register(GArchInstruction *instr, GArc g_object_unref(G_OBJECT(reg)); + g_object_unref(G_OBJECT(op)); + } @@ -107,4 +109,6 @@ void handle_armv7_return_from_pop(GArchInstruction *instr, GArchProcessor *proc, } + g_object_unref(G_OBJECT(op)); + } diff --git a/src/arch/arm/v7/post.c b/src/arch/arm/v7/post.c index 7d8ecb3..46a1792 100644 --- a/src/arch/arm/v7/post.c +++ b/src/arch/arm/v7/post.c @@ -92,6 +92,8 @@ void post_process_ldr_instructions(GArchInstruction *instr, GArchProcessor *proc ppli_release: + g_object_unref(G_OBJECT(op)); + g_arch_instruction_unlock_operands(instr); } diff --git a/src/arch/instruction.c b/src/arch/instruction.c index c11f253..7e1e646 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -191,6 +191,10 @@ static void g_arch_instruction_dispose(GArchInstruction *instr) rem_item_from_flat_array(&instr->operands, 0, sizeof(GArchOperand *)); + /** + * Une fois pour l'obtention, une autre pour la libération ! + */ + g_object_unref(G_OBJECT(op)); g_object_unref(G_OBJECT(op)); } @@ -564,7 +568,7 @@ GArchOperand *_g_arch_instruction_get_operand(const GArchInstruction *instr, siz result = *ptr; - /* TODO : incrémenter la référence ! */ + g_object_ref(G_OBJECT(result)); return result; @@ -635,6 +639,8 @@ bool _g_arch_instruction_replace_operand(GArchInstruction *instr, GArchOperand * break; } + g_object_unref(G_OBJECT(op)); + } if (result) @@ -678,6 +684,8 @@ void _g_arch_instruction_detach_operand(GArchInstruction *instr, GArchOperand *t if (op == target) break; + g_object_unref(G_OBJECT(op)); + } rem_item_from_flat_array(&instr->operands, i, sizeof(GArchOperand *)); @@ -1192,6 +1200,7 @@ static void _g_arch_instruction_print(GArchInstruction *instr, GBufferLine *line { op = _g_arch_instruction_get_operand(instr, 0); g_arch_operand_print(op, line, 0/*syntax*/); + g_object_unref(G_OBJECT(op)); for (i = 1; i < count; i++) { @@ -1202,6 +1211,8 @@ static void _g_arch_instruction_print(GArchInstruction *instr, GBufferLine *line g_arch_operand_print(op, line, 0/*syntax*/); + g_object_unref(G_OBJECT(op)); + } } diff --git a/src/arch/link.c b/src/arch/link.c index fbcd391..2e8e455 100644 --- a/src/arch/link.c +++ b/src/arch/link.c @@ -61,9 +61,7 @@ void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon g_arch_instruction_unlock_operands(instr); - if (!G_IS_IMM_OPERAND(op)) return; - - if (g_imm_operand_to_virt_t(G_IMM_OPERAND(op), &virt)) + if (G_IS_IMM_OPERAND(op) && g_imm_operand_to_virt_t(G_IMM_OPERAND(op), &virt)) { init_vmpa(&addr, VMPA_NO_PHYSICAL, virt); @@ -77,6 +75,8 @@ void handle_jump_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon } + g_object_unref(G_OBJECT(op)); + } @@ -131,6 +131,8 @@ void handle_branch_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcC } } + g_object_unref(G_OBJECT(op)); + if (defined) { target = g_arch_processor_find_instr_by_address(proc, &addr); @@ -191,9 +193,7 @@ void handle_call_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon g_arch_instruction_unlock_operands(instr); - if (!G_IS_IMM_OPERAND(op)) return; - - if (g_imm_operand_to_virt_t(G_IMM_OPERAND(op), &virt)) + if (G_IS_IMM_OPERAND(op) && g_imm_operand_to_virt_t(G_IMM_OPERAND(op), &virt)) { init_vmpa(&addr, VMPA_NO_PHYSICAL, virt); @@ -207,4 +207,6 @@ void handle_call_as_link(GArchInstruction *instr, GArchProcessor *proc, GProcCon } + g_object_unref(G_OBJECT(op)); + } diff --git a/src/arch/post.c b/src/arch/post.c index 59522bf..f3d1fd6 100644 --- a/src/arch/post.c +++ b/src/arch/post.c @@ -119,6 +119,8 @@ void post_process_target_resolution(GArchInstruction *instr, GArchProcessor *pro } + g_object_unref(G_OBJECT(op)); + g_arch_instruction_unlock_operands(instr); } diff --git a/src/arch/raw.c b/src/arch/raw.c index 8ab788f..e85d865 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -468,6 +468,8 @@ static const char *g_raw_instruction_get_keyword(const GRawInstruction *instr, A else size = g_imm_operand_get_size(G_IMM_OPERAND(operand)); + g_object_unref(G_OBJECT(operand)); + return defines[MDS_RANGE(size)]; } @@ -585,6 +587,8 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s string[iter++] = byte; + g_object_unref(G_OBJECT(op)); + continue; grip_fallback: @@ -621,6 +625,8 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s g_arch_operand_print(op, line, 0/*syntax*/); + g_object_unref(G_OBJECT(op)); + } /* Si au final une chaîne traine encore */ |