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



commit 6b278d3f95f400d689abbe1e7a2e17a72e441f38
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Feb 18 23:47:11 2019 +0100

    parser: Don't leak error in error case
    
    RECORD_INITIAL_POS() returns in case of failure, and we leak the
    previously created error as a result.
    
    Fix by calling the macro before allocating the error.
    
    Spotted by coverage.
    
    https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1

 src/cr-parser.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 65052b2..3899a47 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -525,12 +525,12 @@ cr_parser_push_error (CRParser * a_this,
         g_return_val_if_fail (a_this && PRIVATE (a_this)
                               && a_msg, CR_BAD_PARAM_ERROR);
 
+        RECORD_INITIAL_POS (a_this, &pos);
+
         error = cr_parser_error_new (a_msg, a_status);
 
         g_return_val_if_fail (error, CR_ERROR);
 
-        RECORD_INITIAL_POS (a_this, &pos);
-
         cr_parser_error_set_pos
                 (error, pos.line, pos.col, pos.next_byte_index - 1);
 


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