mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 05:06:21 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user