[libgxps] gxps-document: Fix a crash in documents containing nested FixedDocument



commit a5db4274385b840ee7626e4b84fb945cbf44a989
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sat Nov 3 10:16:04 2012 +0100

    gxps-document: Fix a crash in documents containing nested FixedDocument
    
    It's a bug in the document itself, but we shouldn't crash anyway.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685741

 libgxps/gxps-document.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libgxps/gxps-document.c b/libgxps/gxps-document.c
index 867cdb3..ce88206 100644
--- a/libgxps/gxps-document.c
+++ b/libgxps/gxps-document.c
@@ -180,11 +180,13 @@ fixed_doc_end_element (GMarkupParseContext  *context,
 		GList *l;
 
 		data->doc->priv->n_pages = data->n_pages;
-		data->doc->priv->pages = g_new (Page *, data->n_pages);
+                if (data->doc->priv->n_pages > 0) {
+                        data->doc->priv->pages = g_new (Page *, data->n_pages);
 
-		for (l = data->pages; l; l = g_list_next (l))
-			data->doc->priv->pages[--data->n_pages] = (Page *)l->data;
-		g_list_free (data->pages);
+                        for (l = data->pages; l; l = g_list_next (l))
+                                data->doc->priv->pages[--data->n_pages] = (Page *)l->data;
+                }
+                g_list_free (data->pages);
 	} else if (strcmp (element_name, "LinkTarget") == 0) {
 		/* Do Nothing */
 	} else {



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