From 9f1fbd9d729056b624edea563b4cab8e58128b52 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 12 May 2018 11:53:02 +0200 Subject: Fixed some memory leaks. --- plugins/arm/v7/operands/reglist.c | 7 +++++++ plugins/dalvik/operands/register.c | 4 ++++ src/arch/register.c | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/arm/v7/operands/reglist.c b/plugins/arm/v7/operands/reglist.c index 9fe9245..5fc1f08 100644 --- a/plugins/arm/v7/operands/reglist.c +++ b/plugins/arm/v7/operands/reglist.c @@ -120,6 +120,8 @@ static void g_armv7_reglist_operand_class_init(GArmV7RegListOperandClass *klass) static void g_armv7_reglist_operand_init(GArmV7RegListOperand *operand) { + operand->registers = NULL; + operand->count = 0; } @@ -138,6 +140,11 @@ static void g_armv7_reglist_operand_init(GArmV7RegListOperand *operand) static void g_armv7_reglist_operand_dispose(GArmV7RegListOperand *operand) { + size_t i; /* Boucle de parcours */ + + for (i = 0; i < operand->count; i++) + g_object_unref(G_OBJECT(operand->registers[i])); + G_OBJECT_CLASS(g_armv7_reglist_operand_parent_class)->dispose(G_OBJECT(operand)); } diff --git a/plugins/dalvik/operands/register.c b/plugins/dalvik/operands/register.c index 71da97f..d2dd174 100644 --- a/plugins/dalvik/operands/register.c +++ b/plugins/dalvik/operands/register.c @@ -116,6 +116,7 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) { + operand->reg = NULL; operand->is_written = false; } @@ -135,6 +136,9 @@ static void g_dalvik_register_operand_init(GDalvikRegisterOperand *operand) static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *operand) { + if (operand->reg != NULL) + g_object_unref(G_OBJECT(operand->reg)); + G_OBJECT_CLASS(g_dalvik_register_operand_parent_class)->dispose(G_OBJECT(operand)); } diff --git a/src/arch/register.c b/src/arch/register.c index 6194a28..0033071 100644 --- a/src/arch/register.c +++ b/src/arch/register.c @@ -321,6 +321,7 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass) static void g_register_operand_init(GRegisterOperand *operand) { + operand->reg = NULL; operand->is_written = false; } @@ -340,7 +341,8 @@ static void g_register_operand_init(GRegisterOperand *operand) static void g_register_operand_dispose(GRegisterOperand *operand) { - g_object_unref(G_OBJECT(operand->reg)); + if (operand->reg != NULL) + g_object_unref(G_OBJECT(operand->reg)); G_OBJECT_CLASS(g_register_operand_parent_class)->dispose(G_OBJECT(operand)); -- cgit v0.11.2-87-g4458