From 7af6b79557f0aa57200fbd798d3eca604615ee41 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sat, 11 Aug 2018 14:23:28 +0200
Subject: Added a basic check before releasing cached registers.

---
 plugins/arm/v7/registers/banked.c  | 2 +-
 plugins/arm/v7/registers/basic.c   | 2 +-
 plugins/arm/v7/registers/coproc.c  | 2 +-
 plugins/arm/v7/registers/simd.c    | 2 +-
 plugins/arm/v7/registers/special.c | 2 +-
 plugins/dalvik/register.c          | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugins/arm/v7/registers/banked.c b/plugins/arm/v7/registers/banked.c
index c141d74..17eeb28 100644
--- a/plugins/arm/v7/registers/banked.c
+++ b/plugins/arm/v7/registers/banked.c
@@ -713,7 +713,7 @@ void clean_armv7_banked_register_cache(void)
     G_LOCK(_av7_banked_reg_mutex);
 
     for (i = 0; i < _av7_banked_reg_count; i++)
-        g_object_unref(G_OBJECT(_armv7_banked_registers[i]));
+        g_clear_object(&_armv7_banked_registers[i]);
 
     if (_armv7_banked_registers != NULL)
         free(_armv7_banked_registers);
diff --git a/plugins/arm/v7/registers/basic.c b/plugins/arm/v7/registers/basic.c
index 526e864..0a4a768 100644
--- a/plugins/arm/v7/registers/basic.c
+++ b/plugins/arm/v7/registers/basic.c
@@ -448,7 +448,7 @@ void clean_armv7_basic_register_cache(void)
     G_LOCK(_av7_basic_reg_mutex);
 
     for (i = 0; i < _av7_basic_reg_count; i++)
-        g_object_unref(G_OBJECT(_armv7_basic_registers[i]));
+        g_clear_object(&_armv7_basic_registers[i]);
 
     if (_armv7_basic_registers != NULL)
         free(_armv7_basic_registers);
diff --git a/plugins/arm/v7/registers/coproc.c b/plugins/arm/v7/registers/coproc.c
index 8200343..f30edec 100644
--- a/plugins/arm/v7/registers/coproc.c
+++ b/plugins/arm/v7/registers/coproc.c
@@ -428,7 +428,7 @@ void clean_armv7_cp_register_cache(void)
     G_LOCK(_av7_cp_reg_mutex);
 
     for (i = 0; i < _av7_cp_reg_count; i++)
-        g_object_unref(G_OBJECT(_armv7_cp_registers[i]));
+        g_clear_object(&_armv7_cp_registers[i]);
 
     if (_armv7_cp_registers != NULL)
         free(_armv7_cp_registers);
diff --git a/plugins/arm/v7/registers/simd.c b/plugins/arm/v7/registers/simd.c
index ad84ede..ff9a242 100644
--- a/plugins/arm/v7/registers/simd.c
+++ b/plugins/arm/v7/registers/simd.c
@@ -519,7 +519,7 @@ void clean_armv7_simd_register_cache(void)
     for (i = 0; i < SRM_COUNT; i++)
     {
         for (k = 0; k < _av7_simd_reg_count[i]; k++)
-            g_object_unref(G_OBJECT(_armv7_simd_registers[i][k]));
+            g_clear_object(&_armv7_simd_registers[i][k]);
 
         if (_armv7_simd_registers[i] != NULL)
             free(_armv7_simd_registers[i]);
diff --git a/plugins/arm/v7/registers/special.c b/plugins/arm/v7/registers/special.c
index 156b9bf..e0579b4 100644
--- a/plugins/arm/v7/registers/special.c
+++ b/plugins/arm/v7/registers/special.c
@@ -472,7 +472,7 @@ void clean_armv7_special_register_cache(void)
     G_LOCK(_av7_special_reg_mutex);
 
     for (i = 0; i < _av7_special_reg_count; i++)
-        g_object_unref(G_OBJECT(_armv7_special_registers[i]));
+        g_clear_object(&_armv7_special_registers[i]);
 
     if (_armv7_special_registers != NULL)
         free(_armv7_special_registers);
diff --git a/plugins/dalvik/register.c b/plugins/dalvik/register.c
index 0120495..c6bd2c7 100644
--- a/plugins/dalvik/register.c
+++ b/plugins/dalvik/register.c
@@ -501,7 +501,7 @@ void clean_dalvik_register_cache(void)
     G_LOCK(_dreg_mutex);
 
     for (i = 0; i < _dreg_count; i++)
-        g_object_unref(G_OBJECT(_dalvik_registers[i]));
+        g_clear_object(&_dalvik_registers[i]);
 
     if (_dalvik_registers != NULL)
         free(_dalvik_registers);
-- 
cgit v0.11.2-87-g4458