From 2c79b357b245a9691b127aa02cbc9688611490e0 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 17 Jul 2018 12:13:21 +0200 Subject: [PATCH 1/3] gio-tool: Fix a memory leak when returning command line help Coverity CID: #1393952 Signed-off-by: Philip Withnall --- gio/gio-tool-move.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gio/gio-tool-move.c b/gio/gio-tool-move.c index 89c1ed5a5..5755f59d4 100644 --- a/gio/gio-tool-move.c +++ b/gio/gio-tool-move.c @@ -106,6 +106,7 @@ handle_move (int argc, char *argv[], gboolean do_help) if (do_help) { show_help (context, NULL); + g_option_context_free (context); return 0; } From b5948c1a3900f1e795fe7c5a0692bf5bfb518c8f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 17 Jul 2018 12:14:07 +0200 Subject: [PATCH 2/3] gsettings: Fix some memory leaks on error paths Coverity CID: #1393949 Signed-off-by: Philip Withnall --- gio/gsettings.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gio/gsettings.c b/gio/gsettings.c index 194a73778..ab7f43835 100644 --- a/gio/gsettings.c +++ b/gio/gsettings.c @@ -2921,10 +2921,12 @@ g_settings_bind_with_mapping (GSettings *settings, if (!g_variant_type_equal (binding->key.type, G_VARIANT_TYPE_BOOLEAN)) { + gchar *type_string = g_variant_type_dup_string (binding->key.type); g_critical ("g_settings_bind: G_SETTINGS_BIND_INVERT_BOOLEAN " "was specified, but key '%s' on schema '%s' has " "type '%s'", key, g_settings_schema_get_id (settings->priv->schema), - g_variant_type_dup_string (binding->key.type)); + type_string); + g_free (type_string); return; } @@ -2935,12 +2937,14 @@ g_settings_bind_with_mapping (GSettings *settings, !g_settings_mapping_is_compatible (binding->property->value_type, binding->key.type)) { + gchar *type_string = g_variant_type_dup_string (binding->key.type); g_critical ("g_settings_bind: property '%s' on class '%s' has type " "'%s' which is not compatible with type '%s' of key '%s' " "on schema '%s'", binding->property->name, G_OBJECT_TYPE_NAME (object), g_type_name (binding->property->value_type), - g_variant_type_dup_string (binding->key.type), key, + type_string, key, g_settings_schema_get_id (settings->priv->schema)); + g_free (type_string); return; } From e487df31e196609546d72d1f9a420aeb109c8d09 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 17 Jul 2018 12:14:36 +0200 Subject: [PATCH 3/3] gvariant: Fix some memory leaks on error paths Coverity CID: #1393955 Signed-off-by: Philip Withnall --- glib/gvariant.c | 22 ++++++++++++++-------- 1 file 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);