From 217dbbba11ba15e8753e7c5c57bb226df446cf59 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 2 Jan 2014 19:56:56 +0000 Subject: Fix memory leak in pdf_xref_size_from_old_trailer. Thanks to Simon for spotting the original problem. This is a slight tweak on the patch he supplied. --- source/pdf/pdf-xref.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index f3deeebf..a71dc1cf 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -341,6 +341,9 @@ pdf_xref_size_from_old_trailer(pdf_document *doc, pdf_lexbuf *buf) int c; int size; int ofs; + pdf_obj *trailer = NULL; + + fz_var(trailer); /* Record the current file read offset so that we can reinstate it */ ofs = fz_tell(doc->file); @@ -377,7 +380,6 @@ pdf_xref_size_from_old_trailer(pdf_document *doc, pdf_lexbuf *buf) fz_try(doc->ctx) { - pdf_obj *trailer; tok = pdf_lex(doc->file, buf); if (tok != PDF_TOK_TRAILER) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "expected trailer marker"); @@ -391,7 +393,9 @@ pdf_xref_size_from_old_trailer(pdf_document *doc, pdf_lexbuf *buf) size = pdf_to_int(pdf_dict_gets(trailer, "Size")); if (!size) fz_throw(doc->ctx, FZ_ERROR_GENERIC, "trailer missing Size entry"); - + } + fz_always(doc->ctx) + { pdf_drop_obj(trailer); } fz_catch(doc->ctx) -- cgit v1.2.3