From 4184ba5d2930b337fddf3ad8e612a88adb08d8c1 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 5 Apr 2012 12:48:19 +0100 Subject: Don't unlock a lock we don't own. While debugging Bug 692943, I spotted a case where we can attempt to unlock the file while we don't hold the file lock due to an error being thrown while we momentarily drop that lock. Simple solution is to add a new fz_try()/fz_catch() to retake the lock in such an error circumstance. --- pdf/pdf_repair.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'pdf') diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index fda1e6b5..a51b9631 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -390,8 +390,18 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf) if (list[i].stm_len >= 0) { fz_unlock(ctx, FZ_LOCK_FILE); - dict = pdf_load_object(xref, list[i].num, list[i].gen); - fz_lock(ctx, FZ_LOCK_FILE); + fz_try(ctx) + { + dict = pdf_load_object(xref, list[i].num, list[i].gen); + } + fz_always(ctx) + { + fz_lock(ctx, FZ_LOCK_FILE); + } + fz_catch(ctx) + { + fz_rethrow(ctx); + } /* RJW: "cannot load stream object (%d %d R)", list[i].num, list[i].gen */ length = pdf_new_int(ctx, list[i].stm_len); -- cgit v1.2.3