[libcroco/wip/fmuellner/coverage-fixes: 8/12] statement: Avoid leaks by early return



commit 43590c3f8189dffa5494d1a9be02837d51b1ab33
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 19 00:59:37 2019 +0100

    statement: Avoid leaks by early return
    
    Spotted by covscan.
    
    https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1

 src/cr-statement.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/cr-statement.c b/src/cr-statement.c
index 241fa5f..00430d5 100644
--- a/src/cr-statement.c
+++ b/src/cr-statement.c
@@ -317,15 +317,15 @@ parse_at_media_property_cb (CRDocHandler * a_this,
 
         g_return_if_fail (a_this && a_name);
 
-        name = cr_string_dup (a_name) ;
-        g_return_if_fail (name);
-
        stmtptr = &stmt;
         status = cr_doc_handler_get_ctxt (a_this, 
                                           (gpointer *) stmtptr);
         g_return_if_fail (status == CR_OK && stmt);
         g_return_if_fail (stmt->type == RULESET_STMT);
 
+        name = cr_string_dup (a_name) ;
+        g_return_if_fail (name);
+
         decl = cr_declaration_new (stmt, name, a_value);
         g_return_if_fail (decl);
         decl->important = a_important;
@@ -424,15 +424,15 @@ parse_ruleset_property_cb (CRDocHandler * a_this,
 
         g_return_if_fail (a_this && a_this->priv && a_name);
 
-        stringue = cr_string_dup (a_name);
-        g_return_if_fail (stringue);
-
        rulesetptr = &ruleset;
         status = cr_doc_handler_get_result (a_this, (gpointer *) rulesetptr);
         g_return_if_fail (status == CR_OK
                           && ruleset 
                           && ruleset->type == RULESET_STMT);
 
+        stringue = cr_string_dup (a_name);
+        g_return_if_fail (stringue);
+
         decl = cr_declaration_new (ruleset, stringue, a_value);
         g_return_if_fail (decl);
         decl->important = a_important;


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