[gobject-introspection] girepository: Fix leak in prefix_with_context



commit 4dcc1b3536d0e9f12d510b8489771e72a9ca7282
Author: David King <dking redhat com>
Date:   Thu May 20 12:48:34 2021 +0100

    girepository: Fix leak in prefix_with_context
    
    Found by Coverity.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1938731

 girepository/gitypelib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c
index de11748b..904dff45 100644
--- a/girepository/gitypelib.c
+++ b/girepository/gitypelib.c
@@ -2139,7 +2139,7 @@ prefix_with_context (GError **error,
                     const char *section,
                     ValidateContext *ctx)
 {
-  GString *str = g_string_new (NULL);
+  GString *str;
   GSList *link;
   char *buf;
 
@@ -2150,6 +2150,8 @@ prefix_with_context (GError **error,
       return;
     }
 
+  str = g_string_new (NULL);
+
   for (; link; link = link->next)
     {
       g_string_append (str, link->data);


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