[libcroco/wip/fmuellner/coverage-fixes: 7/12] om-parser: Fix string leak on error



commit f652b124c924dc7969c880ef5998df93739953c9
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 19 00:28:07 2019 +0100

    om-parser: Fix string leak on error
    
    The string is taken by the declaration on success, but currently
    leaked on failure.
    
    Spotted by coverage.
    
    https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1

 src/cr-om-parser.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c
index 4576199..f2b4ff3 100644
--- a/src/cr-om-parser.c
+++ b/src/cr-om-parser.c
@@ -669,6 +669,8 @@ property (CRDocHandler * a_this,
 
         /*instanciates a new declaration */
         decl = cr_declaration_new (ctxt->cur_stmt, str, a_expression);
+        if (decl == NULL)
+                g_clear_pointer (&str, cr_string_destroy);
         g_return_if_fail (decl);
         str = NULL;
         decl->important = a_important;


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