[libgxps] Fixed memory leak when parsing fails for a child element of a Glyphs



commit 19e5c5834d493075283d82a0d8d410463646c849
Author: Jason Crain <jason aquaticape us>
Date:   Sat Dec 24 12:24:11 2011 -0600

    Fixed memory leak when parsing fails for a child element of a Glyphs
    
    A GXPSGlyphs struct is leaked when parsing fails for a child element
    of a Glyphs.  Parsing is aborted when invalid data is encountered and
    cleanup code is not run.  This adds a error handler to the glyphs
    GMarkupParser to free the struct on error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668966

 libgxps/gxps-glyphs.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/libgxps/gxps-glyphs.c b/libgxps/gxps-glyphs.c
index d8de220..3b89526 100644
--- a/libgxps/gxps-glyphs.c
+++ b/libgxps/gxps-glyphs.c
@@ -630,11 +630,21 @@ glyphs_end_element (GMarkupParseContext  *context,
         }
 }
 
+static void
+glyphs_error (GMarkupParseContext *context,
+              GError              *error,
+              gpointer             user_data)
+{
+	GXPSGlyphs *glyphs = (GXPSGlyphs *)user_data;
+	gxps_glyphs_free (glyphs);
+}
+
 static GMarkupParser glyphs_parser = {
         glyphs_start_element,
         glyphs_end_element,
         NULL,
-        NULL
+        NULL,
+        glyphs_error
 };
 
 void



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