summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2018-07-17 12:14:36 +0200
committerPhilip Withnall <philip@tecnocode.co.uk>2018-07-17 12:14:36 +0200
commite487df31e196609546d72d1f9a420aeb109c8d09 (patch)
tree9ce5eeb1af6899f5143c3e29856191271628e541
parentb5948c1a3900f1e795fe7c5a0692bf5bfb518c8f (diff)
downloadglib-e487df31e196609546d72d1f9a420aeb109c8d09.tar.gz
gvariant: Fix some memory leaks on error paths
Coverity CID: #1393955 Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
-rw-r--r--glib/gvariant.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 6a9b37c9a..4dbce8c60 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -4738,10 +4738,13 @@ g_variant_valist_new_nnp (const gchar **str,
type = g_variant_type_element (type);
if G_UNLIKELY (!g_variant_type_is_subtype_of (type, (GVariantType *) *str))
- g_error ("g_variant_new: expected GVariantBuilder array element "
- "type '%s' but the built value has element type '%s'",
- g_variant_type_dup_string ((GVariantType *) *str),
- g_variant_get_type_string (value) + 1);
+ {
+ gchar *type_string = g_variant_type_dup_string ((GVariantType *) *str);
+ g_error ("g_variant_new: expected GVariantBuilder array element "
+ "type '%s' but the built value has element type '%s'",
+ type_string, g_variant_get_type_string (value) + 1);
+ g_free (type_string);
+ }
g_variant_type_string_scan (*str, NULL, str);
@@ -4803,10 +4806,13 @@ g_variant_valist_new_nnp (const gchar **str,
case '@':
if G_UNLIKELY (!g_variant_is_of_type (ptr, (GVariantType *) *str))
- g_error ("g_variant_new: expected GVariant of type '%s' but "
- "received value has type '%s'",
- g_variant_type_dup_string ((GVariantType *) *str),
- g_variant_get_type_string (ptr));
+ {
+ gchar *type_string = g_variant_type_dup_string ((GVariantType *) *str);
+ g_error ("g_variant_new: expected GVariant of type '%s' but "
+ "received value has type '%s'",
+ type_string, g_variant_get_type_string (ptr));
+ g_free (type_string);
+ }
g_variant_type_string_scan (*str, NULL, str);