[libcroco] cr-om-parser: Stop memory leak



commit 30ca729728e28ea3f6dcb09cb7bfc06434a72197
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Jun 24 15:47:13 2012 -0400

    cr-om-parser: Stop memory leak
    
    The parser refs the doc handler, so we need to unref it here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678736

 src/cr-om-parser.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/src/cr-om-parser.c b/src/cr-om-parser.c
index a62e98d..ea622e3 100644
--- a/src/cr-om-parser.c
+++ b/src/cr-om-parser.c
@@ -142,7 +142,7 @@ static enum CRStatus
 cr_om_parser_init_default_sac_handler (CROMParser * a_this)
 {
         CRDocHandler *sac_handler = NULL;
-        gboolean free_hdlr_if_error = FALSE;
+        gboolean created_handler = FALSE;
         enum CRStatus status = CR_OK;
 
         g_return_val_if_fail (a_this && PRIVATE (a_this)
@@ -155,7 +155,7 @@ cr_om_parser_init_default_sac_handler (CROMParser * a_this)
 
         if (!sac_handler) {
                 sac_handler = cr_doc_handler_new ();
-                free_hdlr_if_error = TRUE;
+                created_handler = TRUE;
         }
 
         /*
@@ -177,15 +177,10 @@ cr_om_parser_init_default_sac_handler (CROMParser * a_this)
         sac_handler->end_media = end_media;
         sac_handler->import_style = import_style;
 
-        status = cr_parser_set_sac_handler (PRIVATE (a_this)->parser,
-                                            sac_handler);
-        if (status == CR_OK) {
-                return CR_OK;
-        }
-
-        if (sac_handler && free_hdlr_if_error == TRUE) {
-                cr_doc_handler_destroy (sac_handler);
-                sac_handler = NULL;
+        if (created_handler) {
+                status = cr_parser_set_sac_handler (PRIVATE (a_this)->parser,
+                                                    sac_handler);
+                cr_doc_handler_unref (sac_handler);
         }
 
         return status;



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