summaryrefslogtreecommitdiff
path: root/apps/pdfclean.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-12-24 12:55:21 +0000
committerRobin Watts <robin.watts@artifex.com>2012-12-24 13:58:23 +0000
commit12f83ab602f913e8e34aab5348339bccc8ace53e (patch)
tree3e0aa6592259c15c8de594bc8ad31ca19e68a805 /apps/pdfclean.c
parent6f1b7687de910617cbbf0ea2fb926751782294cd (diff)
downloadmupdf-12f83ab602f913e8e34aab5348339bccc8ace53e.tar.xz
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!
Diffstat (limited to 'apps/pdfclean.c')
-rw-r--r--apps/pdfclean.c5
1 files changed, 5 insertions, 0 deletions
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;
}