[libcroco/wip/fmuellner/coverage-fixes: 10/12] statement: Don't leak new statement objects on failure



commit 32bc471aa5646edc0356126b3b7e30e214f5669a
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 19 01:02:06 2019 +0100

    statement: Don't leak new statement objects on failure
    
    cr_statement_new_with_media_rule() may fail and return NULL. The
    previously allocated memory should be freed in that case.
    
    Spotted by coverage.
    
    https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1

 src/cr-statement.c | 1 +
 1 file changed, 1 insertion(+)
---
diff --git a/src/cr-statement.c b/src/cr-statement.c
index 8463fcb..b38c076 100644
--- a/src/cr-statement.c
+++ b/src/cr-statement.c
@@ -1310,6 +1310,7 @@ cr_statement_new_at_media_rule (CRStyleSheet * a_sheet,
         return result;
 
       error:
+        g_clear_pointer (&result, cr_statement_destroy);
         return NULL;
 }
 


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