From 3f88a10ad8fc3da8c582c4524225e59cdfff12e5 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 5 Mar 2014 20:59:10 +0000 Subject: Don't drop objects if they have been modified. This avoids leaks when pdf_clear_xref etc are used. --- source/pdf/pdf-xref.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index f9b72a4d..ef238fb1 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -2491,7 +2491,9 @@ void pdf_clear_xref(pdf_document *doc) { pdf_xref_entry *entry = &xref->table[e]; - if (entry->obj) + /* We cannot drop objects if the stream buffer has + * been updated */ + if (entry->obj != NULL && entry->stm_buf == NULL) { if (pdf_obj_refs(entry->obj) == 1) { @@ -2515,7 +2517,9 @@ void pdf_clear_xref_to_mark(pdf_document *doc) { pdf_xref_entry *entry = &xref->table[e]; - if (entry->obj) + /* We cannot drop objects if the stream buffer has + * been updated */ + if (entry->obj != NULL && entry->stm_buf == NULL) { if ((entry->flags & PDF_OBJ_FLAG_MARK) == 0 && pdf_obj_refs(entry->obj) == 1) { -- cgit v1.2.3