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



commit a1e36e02c944040bf23ba1c2b76bbff2dfad0169
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Feb 18 23:46:39 2019 +0100

    parser: Don't leak pseudo in error case
    
    Spotted by coverage.
    
    https://gitlab.gnome.org/GNOME/libcroco/merge_requests/1

 src/cr-parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/cr-parser.c b/src/cr-parser.c
index 18c9a01..65052b2 100644
--- a/src/cr-parser.c
+++ b/src/cr-parser.c
@@ -1665,6 +1665,7 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
         CRInputPos init_pos;
         CRToken *token = NULL;
         CRSimpleSel *sel = NULL;
+        CRPseudo *pseudo = NULL;
         CRAdditionalSel *add_sel_list = NULL;
         gboolean found_sel = FALSE;
         guint32 cur_char = 0;
@@ -1798,7 +1799,6 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
                                  &attr_sel->location) ;
                 } else if (token && (token->type == DELIM_TK)
                            && (token->u.unichar == ':')) {
-                        CRPseudo *pseudo = NULL;
 
                         /*try to parse a pseudo */
 
@@ -1890,6 +1890,8 @@ cr_parser_parse_simple_selector (CRParser * a_this, CRSimpleSel ** a_sel)
 
  error:
 
+        g_clear_pointer (&pseudo, cr_pseudo_destroy);
+
         if (token) {
                 cr_token_destroy (token);
                 token = NULL;


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