diff options
author | Robin Watts <robin.watts@artifex.com> | 2014-01-02 19:56:56 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-01-02 20:04:35 +0000 |
commit | 217dbbba11ba15e8753e7c5c57bb226df446cf59 (patch) | |
tree | 882482c0b28fc6651e682ad5ef988a724289c45b | |
parent | f030651e6f4d79572b1daf2a480369d5d881645f (diff) | |
download | mupdf-217dbbba11ba15e8753e7c5c57bb226df446cf59.tar.xz |
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.
-rw-r--r-- | source/pdf/pdf-xref.c | 8 |
1 files changed, 6 insertions, 2 deletions
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) |