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



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

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

 src/cr-parser.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 3899a47..44043b7 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -2761,6 +2761,8 @@ cr_parser_new (CRTknzr * a_tknzr)
 
         if (a_tknzr) {
                 status = cr_parser_set_tknzr (result, a_tknzr);
+                if (status != CR_OK)
+                        cr_parser_destroy (result);
         }
 
         g_return_val_if_fail (status == CR_OK, NULL);


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