[gnome-software/wip/static-analyzer] gs-plugin-appstream: Fix a memory leak in failure branch



commit adc6b658b6e8c302865d419912a831b1b3565159
Author: Milan Crha <mcrha redhat com>
Date:   Mon Apr 4 18:12:10 2022 +0200

    gs-plugin-appstream: Fix a memory leak in failure branch
    
    When a file load failed the `media_baseurl` GString was leaked.
    Allocate it internally to the function it uses it only.

 plugins/core/gs-plugin-appstream.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index cec8160e3..55569c1e0 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -472,7 +472,6 @@ gs_plugin_appstream_load_appstream_fn (GsPluginAppstream  *self,
        g_autoptr(XbBuilderFixup) fixup4 = NULL;
 #endif
        g_autoptr(XbBuilderFixup) fixup5 = NULL;
-       GString *media_baseurl = g_string_new (NULL);
        g_autoptr(XbBuilderSource) source = xb_builder_source_new ();
 
        /* add support for DEP-11 files */
@@ -531,7 +530,7 @@ gs_plugin_appstream_load_appstream_fn (GsPluginAppstream  *self,
        /* prepend media_baseurl to remote relative URLs */
        fixup5 = xb_builder_fixup_new ("MediaBaseUrl",
                                       gs_plugin_appstream_media_baseurl_cb,
-                                      media_baseurl,
+                                      g_string_new (NULL),
                                       gs_plugin_appstream_media_baseurl_free);
        xb_builder_fixup_set_max_depth (fixup5, 3);
        xb_builder_source_add_fixup (source, fixup5);


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