[gnome-software] trivial: Fix a small memory leak in gs_app_set_metadata()



commit 67e61f58164fad199078649aca1a14dfd3305a9e
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 19 17:20:10 2017 +0100

    trivial: Fix a small memory leak in gs_app_set_metadata()

 lib/gs-app.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index a832803..d943714 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -2990,10 +2990,12 @@ gs_app_get_metadata_item (GsApp *app, const gchar *key)
 void
 gs_app_set_metadata (GsApp *app, const gchar *key, const gchar *value)
 {
+       g_autoptr(GVariant) tmp = NULL;
        g_return_if_fail (GS_IS_APP (app));
        g_return_if_fail (key != NULL);
-       gs_app_set_metadata_variant (app, key,
-                                    value != NULL ? g_variant_new_string (value) : NULL);
+       if (value != NULL)
+               tmp = g_variant_new_string (value);
+       gs_app_set_metadata_variant (app, key, tmp);
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]