Don't leak memory here.

2005-06-23  Matthias Clasen  <mclasen@redhat.com>

	* tests/keyfile-test.c (test_group_remove): Don't leak
	memory here.

	* glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't
	leak output_path.  (#308546, Kjartan Maraas)
This commit is contained in:
Matthias Clasen 2005-06-23 16:28:55 +00:00 committed by Matthias Clasen
parent f3a61fe4a0
commit 58f83683e9
6 changed files with 27 additions and 7 deletions

View File

@ -1,5 +1,8 @@
2005-06-23 Matthias Clasen <mclasen@redhat.com> 2005-06-23 Matthias Clasen <mclasen@redhat.com>
* tests/keyfile-test.c (test_group_remove): Don't leak
memory here.
* glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't * glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't
leak output_path. (#308546, Kjartan Maraas) leak output_path. (#308546, Kjartan Maraas)

View File

@ -1,5 +1,8 @@
2005-06-23 Matthias Clasen <mclasen@redhat.com> 2005-06-23 Matthias Clasen <mclasen@redhat.com>
* tests/keyfile-test.c (test_group_remove): Don't leak
memory here.
* glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't * glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't
leak output_path. (#308546, Kjartan Maraas) leak output_path. (#308546, Kjartan Maraas)

View File

@ -1,5 +1,8 @@
2005-06-23 Matthias Clasen <mclasen@redhat.com> 2005-06-23 Matthias Clasen <mclasen@redhat.com>
* tests/keyfile-test.c (test_group_remove): Don't leak
memory here.
* glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't * glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't
leak output_path. (#308546, Kjartan Maraas) leak output_path. (#308546, Kjartan Maraas)

View File

@ -1,5 +1,8 @@
2005-06-23 Matthias Clasen <mclasen@redhat.com> 2005-06-23 Matthias Clasen <mclasen@redhat.com>
* tests/keyfile-test.c (test_group_remove): Don't leak
memory here.
* glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't * glib/gkeyfile.c (g_key_file_load_from_data_dirs): Don't
leak output_path. (#308546, Kjartan Maraas) leak output_path. (#308546, Kjartan Maraas)

View File

@ -587,8 +587,11 @@ g_key_file_load_from_data_dirs (GKeyFile *key_file,
found_file = FALSE; found_file = FALSE;
data_dirs = all_data_dirs; data_dirs = all_data_dirs;
output_path = NULL;
while (*data_dirs != NULL && !found_file) while (*data_dirs != NULL && !found_file)
{ {
g_free (output_path);
fd = find_file_in_data_dirs (file, &output_path, &data_dirs, fd = find_file_in_data_dirs (file, &output_path, &data_dirs,
&key_file_error); &key_file_error);
@ -606,15 +609,14 @@ g_key_file_load_from_data_dirs (GKeyFile *key_file,
if (key_file_error) if (key_file_error)
{ {
g_propagate_error (error, key_file_error); g_propagate_error (error, key_file_error);
g_free (output_path);
break; break;
} }
}
if (full_path) if (found_file && full_path)
*full_path = output_path; *full_path = output_path;
else else
g_free (output_path); g_free (output_path);
}
g_strfreev (all_data_dirs); g_strfreev (all_data_dirs);

View File

@ -708,6 +708,8 @@ test_group_remove (void)
g_key_file_remove_group (keyfile, "group1", &error); g_key_file_remove_group (keyfile, "group1", &error);
check_no_error (&error); check_no_error (&error);
g_strfreev (names);
names = g_key_file_get_groups (keyfile, &len); names = g_key_file_get_groups (keyfile, &len);
if (names == NULL) if (names == NULL)
{ {
@ -722,6 +724,8 @@ test_group_remove (void)
g_key_file_remove_group (keyfile, "group2", &error); g_key_file_remove_group (keyfile, "group2", &error);
check_no_error (&error); check_no_error (&error);
g_strfreev (names);
names = g_key_file_get_groups (keyfile, &len); names = g_key_file_get_groups (keyfile, &len);
if (names == NULL) if (names == NULL)
{ {
@ -735,6 +739,8 @@ test_group_remove (void)
g_key_file_remove_group (keyfile, "no such group", &error); g_key_file_remove_group (keyfile, "no such group", &error);
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
g_strfreev (names);
g_key_file_free (keyfile); g_key_file_free (keyfile);
} }