From bbe9de65a14a7940572494f143b6faf3d1353d26 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Mon, 2 Oct 2023 09:18:39 +0200
Subject: Fix memory leaks.

---
 src/analysis/scan/core.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/analysis/scan/core.c b/src/analysis/scan/core.c
index 6316a53..7b11504 100644
--- a/src/analysis/scan/core.c
+++ b/src/analysis/scan/core.c
@@ -128,12 +128,14 @@ bool load_all_known_scan_token_modifiers(void)
 
     result = true;
 
-#define REGISTER_SCAN_MODIFIER(m)                   \
-    ({                                              \
-        bool __status;                              \
-        __status = register_scan_token_modifier(m); \
-        g_object_unref(G_OBJECT(m));                \
-        __status;                                   \
+#define REGISTER_SCAN_MODIFIER(m)                       \
+    ({                                                  \
+        GScanTokenModifier *__mod;                      \
+        bool __status;                                  \
+        __mod = m;                                      \
+        __status = register_scan_token_modifier(__mod); \
+        g_object_unref(G_OBJECT(__mod));                \
+        __status;                                       \
     })
 
     if (result) result = REGISTER_SCAN_MODIFIER(g_scan_hex_modifier_new());
@@ -234,12 +236,14 @@ bool populate_main_scan_namespace(GScanNamespace *space)
 
     result = true;
 
-#define REGISTER_FUNC(s, f)                                 \
-    ({                                                      \
-        bool __result;                                      \
-        __result = g_scan_namespace_register_item(s, f);    \
-        g_object_unref(G_OBJECT(f));                        \
-        __result;                                           \
+#define REGISTER_FUNC(s, f)                                     \
+    ({                                                          \
+        GRegisteredItem *__item;                                \
+        bool __result;                                          \
+        __item = f;                                             \
+        __result = g_scan_namespace_register_item(s, __item);   \
+        g_object_unref(G_OBJECT(__item));                       \
+        __result;                                               \
     })
 
     if (result) result = REGISTER_FUNC(space, g_scan_count_function_new());
-- 
cgit v0.11.2-87-g4458