summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorPaul Gardiner <paul@glidos.net>2012-06-15 16:25:15 +0100
committerPaul Gardiner <paul@glidos.net>2012-06-15 16:25:15 +0100
commit2972aa7531a3cd810e245c4fab7ebd71c583fca2 (patch)
treeb3c77b9ad72e9d780bd90d0b2c47c840a0cee35f /pdf
parent7f04d49cf7857be483c3f0018d32e2714d344944 (diff)
downloadmupdf-2972aa7531a3cd810e245c4fab7ebd71c583fca2.tar.xz
Fix bug 693128: MuPDF forms support: crash on button click
Fix one pdf_js function that didn't protect agains doc->js == NULL. Also change exception handling in pdf_new_js so that it doesn't abort just because of a single failed stream load.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_js.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/pdf/pdf_js.c b/pdf/pdf_js.c
index 348382ab..b4cc2a3c 100644
--- a/pdf/pdf_js.c
+++ b/pdf/pdf_js.c
@@ -288,17 +288,26 @@ pdf_js *pdf_new_js(pdf_document *doc)
unsigned char *buf;
int len;
- fzbuf = pdf_load_stream(doc, pdf_to_num(code), pdf_to_gen(code));
- len = fz_buffer_storage(ctx, fzbuf, &buf);
- pdf_jsimp_execute_count(js->imp, buf, len);
- fz_drop_buffer(ctx, fzbuf);
- fzbuf = NULL;
+ fz_try(ctx)
+ {
+ fzbuf = pdf_load_stream(doc, pdf_to_num(code), pdf_to_gen(code));
+ len = fz_buffer_storage(ctx, fzbuf, &buf);
+ pdf_jsimp_execute_count(js->imp, buf, len);
+ }
+ fz_always(ctx)
+ {
+ fz_drop_buffer(ctx, fzbuf);
+ fzbuf = NULL;
+ }
+ fz_catch(ctx)
+ {
+ fz_warn(ctx, "Warning: %s", ctx->error->message);
+ }
}
}
}
fz_always(ctx)
{
- fz_drop_buffer(ctx, fzbuf);
pdf_drop_obj(javascript);
}
fz_catch(ctx)
@@ -324,7 +333,8 @@ void pdf_drop_js(pdf_js *js)
void pdf_js_setup_event(pdf_js *js, pdf_obj *target)
{
- js->event.target = target;
+ if (js)
+ js->event.target = target;
}
void pdf_js_execute(pdf_js *js, char *code)