summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2016-03-21 12:44:15 +0000
committerPhilip Withnall <philip.withnall@collabora.co.uk>2016-03-21 12:44:15 +0000
commitc7763d0712696ae153f2405017221050637908f3 (patch)
treeefe402988f39bfabab30838a0a9769b412c39331
parent58f56b24601838d76a8fda7bd48f0ebe0f9758b5 (diff)
downloadglib-c7763d0712696ae153f2405017221050637908f3.tar.gz
glib-compile-resources: Fix minor memory leak on error path
Spotted by Coverity (CID: #1353385).
-rw-r--r--gio/glib-compile-resources.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index b84f0e4cd..e1223d6a8 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -216,7 +216,7 @@ end_element (GMarkupParseContext *context,
{
gchar *file, *real_file;
gchar *key;
- FileData *data;
+ FileData *data = NULL;
char *tmp_file = NULL;
char *tmp_file2 = NULL;
@@ -238,8 +238,6 @@ end_element (GMarkupParseContext *context,
return;
}
- data = g_new0 (FileData, 1);
-
if (sourcedirs != NULL)
{
real_file = find_file (file);
@@ -263,6 +261,7 @@ end_element (GMarkupParseContext *context,
real_file = g_strdup (file);
}
+ data = g_new0 (FileData, 1);
data->filename = g_strdup (real_file);
if (!state->collect_data)
goto done;
@@ -416,6 +415,7 @@ end_element (GMarkupParseContext *context,
done:
g_hash_table_insert (state->table, key, data);
+ data = NULL;
cleanup:
/* Cleanup */
@@ -440,6 +440,9 @@ end_element (GMarkupParseContext *context,
unlink (tmp_file2);
g_free (tmp_file2);
}
+
+ if (data != NULL)
+ file_data_free (data);
}
}