tests: Fix a minor leak in the utils test

Found with `meson test --setup valgrind`, although I also had to change
relevant lines in `glib/tests/meson.build` temporarily to avoid the
other tests in the file taking forever:
```
  'utils' : {
    'c_standards': c_standards.keys(),
    'args': ['-p', '/utils/user-special-dirs'],
  },
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall
2025-09-18 16:28:45 +01:00
parent 2258775871
commit f7fca2e9b6

View File

@@ -856,6 +856,7 @@ test_user_special_dirs_load_unlocked (void)
if (g_test_subprocess ())
{
gchar *user_dirs_file;
char *user_dirs_parent = NULL;
const gchar *config_dir;
const gchar *dir;
gchar *expected;
@@ -863,7 +864,8 @@ test_user_special_dirs_load_unlocked (void)
config_dir = g_get_user_config_dir ();
user_dirs_file = g_build_filename (config_dir, "user-dirs.dirs", NULL);
g_mkdir_with_parents (g_path_get_dirname (user_dirs_file), 0700);
user_dirs_parent = g_path_get_dirname (user_dirs_file);
g_mkdir_with_parents (user_dirs_parent, 0700);
result = g_file_set_contents (user_dirs_file,
"XDG_DESKTOP_DIR = \"/root\"\nXDG_DESKTOP_DIR = \"$HOMER/Desktop\"\n"
"XDG_DOCUMENTS_DIR = \"$HOME\"\n"
@@ -873,6 +875,7 @@ test_user_special_dirs_load_unlocked (void)
-1, NULL);
g_assert_true (result);
g_free (user_dirs_file);
g_free (user_dirs_parent);
g_reload_user_special_dirs_cache ();