From 12f83ab602f913e8e34aab5348339bccc8ace53e Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 24 Dec 2012 12:55:21 +0000 Subject: Bug 693503: Fix leak while writing a broken file. While investigating samples_mupdf_001/2599.pdf.asan.58.1778, a leak showed up while cleaning the file, due to not dropping an object in an error case. mutool clean -dif samples_mupdf_001/2599.pdf.asan.58.1778 leak.pdf Simple Fix. Also extend PDF writing so that it can cope with skipping errors so we at least get something out at the end. Problem found in a test file supplied by Mateusz "j00ru" Jurczyk and Gynvael Coldwind of the Google Security Team using Address Sanitizer. Many thanks! --- apps/pdfclean.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apps/pdfclean.c') diff --git a/apps/pdfclean.c b/apps/pdfclean.c index 409d4fbb..e892db29 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -162,11 +162,14 @@ int pdfclean_main(int argc, char **argv) int subset; fz_write_options opts; int write_failed = 0; + int errors = 0; opts.do_garbage = 0; opts.do_expand = 0; opts.do_ascii = 0; opts.do_linear = 0; + opts.continue_on_error = 1; + opts.errors = &errors; while ((c = fz_getopt(argc, argv, "adfgilp:")) != -1) { @@ -229,5 +232,7 @@ int pdfclean_main(int argc, char **argv) fz_free_context(ctx); + if (errors) + write_failed = 1; return write_failed ? 1 : 0; } -- cgit v1.2.3