summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2012-08-05 15:37:56 +0200
committerSebastian Rasmussen <sebras@gmail.com>2012-08-06 14:01:05 +0200
commit0fda4705b3194d2158f4dd3998981884cb3e8570 (patch)
tree5146357e7d81388f0181fc8fe15dc5feed009ec5
parent0a19ed89da833569e014a05e2077a0819a91e5aa (diff)
downloadmupdf-0fda4705b3194d2158f4dd3998981884cb3e8570.tar.xz
Upon parse error when repairing, make sure object stream is freed
Previously, during repair of a pdf, an object stream was loaded and an attempt was made at repairing the objects stored inside the object stream. Failure to repair the stream caused an exception which was not handled by the code loading the object stream, it was just passed on. This meant that the loaded object stream caused a memory leak. Now we catch that exception, free the object stream and rethrow the exception.
-rw-r--r--pdf/pdf_repair.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c
index e892bc52..8250ebf4 100644
--- a/pdf/pdf_repair.c
+++ b/pdf/pdf_repair.c
@@ -506,6 +506,7 @@ pdf_repair_xref(pdf_document *xref, pdf_lexbuf *buf)
void
pdf_repair_obj_stms(pdf_document *xref)
{
+ fz_context *ctx = xref->ctx;
pdf_obj *dict;
int i;
@@ -514,9 +515,19 @@ pdf_repair_obj_stms(pdf_document *xref)
if (xref->table[i].stm_ofs)
{
dict = pdf_load_object(xref, i, 0);
- if (!strcmp(pdf_to_name(pdf_dict_gets(dict, "Type")), "ObjStm"))
- pdf_repair_obj_stm(xref, i, 0);
- pdf_drop_obj(dict);
+ fz_try(ctx)
+ {
+ if (!strcmp(pdf_to_name(pdf_dict_gets(dict, "Type")), "ObjStm"))
+ pdf_repair_obj_stm(xref, i, 0);
+ }
+ fz_always(ctx)
+ {
+ pdf_drop_obj(dict);
+ }
+ fz_catch(ctx)
+ {
+ fz_rethrow(ctx);
+ }
}
}