test(ai): prevent memory leak in provider cycle test
Some checks failed
CI Code / Check spelling (pull_request) Successful in 16s
CI Code / Check coding style (pull_request) Successful in 31s
CI Code / Code Coverage (pull_request) Successful in 2m32s
CI Code / Linux (debian) (pull_request) Failing after 3m33s
CI Code / Linux (ubuntu) (pull_request) Failing after 3m44s
CI Code / Linux (arch) (pull_request) Failing after 4m25s

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.
This commit is contained in:
2026-05-14 20:56:35 +00:00
parent 33929e2ae7
commit 3c021c754d

View File

@@ -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);