[libcroco/wip/fmuellner/coverage-fixes: 6/12] om-parser: Don't leak charset in error case



commit deea1fb73466f7f3a383c01703342d73f73d78ef
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Feb 19 00:20:45 2019 +0100

    om-parser: Don't leak charset in error case
    
    It is freed correctly if creating stmt2 fails, but leaked in case
    of stmt. Adjust the code so that the cleanup is run for both cases.
    
    Spotted by covscan.
    
    https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1

 src/cr-om-parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c
index 348cd1f..4576199 100644
--- a/src/cr-om-parser.c
+++ b/src/cr-om-parser.c
@@ -318,8 +318,8 @@ charset (CRDocHandler * a_this, CRString * a_charset,
 
         charset = cr_string_dup (a_charset) ;
         stmt = cr_statement_new_at_charset_rule (ctxt->stylesheet, charset);
-        g_return_if_fail (stmt);
-        stmt2 = cr_statement_append (ctxt->stylesheet->statements, stmt);
+        if (stmt)
+                stmt2 = cr_statement_append (ctxt->stylesheet->statements, stmt);
         if (!stmt2) {
                 if (stmt) {
                         cr_statement_destroy (stmt);


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