From 3c021c754d796a4b440e3b84fe9a23be3f531804 Mon Sep 17 00:00:00 2001 From: Jabber Developer Date: Thu, 14 May 2026 20:56:35 +0000 Subject: [PATCH] test(ai): prevent memory leak in provider cycle test Use g_hash_table_new_full with g_free to ensure provider names are properly freed when removed from the hash table. Add missing glib.h include. --- tests/unittests/test_ai_client.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unittests/test_ai_client.c b/tests/unittests/test_ai_client.c index 063bfd52..20783f17 100644 --- a/tests/unittests/test_ai_client.c +++ b/tests/unittests/test_ai_client.c @@ -1,3 +1,4 @@ +#include "glib.h" #include "prof_cmocka.h" #include "common.h" #include "ai/ai_client.h" @@ -1142,7 +1143,7 @@ test_ai_providers_find_cycles_through_many(void** state) ai_add_provider("alpine", "https://al.example/"); /* Three providers share prefix "alp": alpha, alphabet, alpine. */ - GHashTable* seen = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable* seen = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); for (int i = 0; i < 3; i++) { auto_gchar gchar* match = ai_providers_find("alp", FALSE, NULL);