summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-07-12 13:37:02 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-07-12 14:45:46 +0200
commitddc05633ee52a5ec2e378d40033d4f3cab115061 (patch)
tree2c6de7a55a88e6cef33f77746a066393a9d16b4a
parente3d769c16d22f42a2fa60ad5c375ffd7738a8a44 (diff)
downloadmupdf-ddc05633ee52a5ec2e378d40033d4f3cab115061.tar.xz
js: Check if some arguments exist before converting to boolean/number.
-rw-r--r--source/tools/murun.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index bf329540..f68d7405 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1266,7 +1266,7 @@ static void ffi_readFile(js_State *J)
static void ffi_new_Buffer(js_State *J)
{
fz_context *ctx = js_getcontext(J);
- int n = js_tonumber(J, 1);
+ int n = js_isdefined(J, 1) ? js_tonumber(J, 1) : 0;
fz_buffer *buf;
fz_try(ctx)
buf = fz_new_buffer(ctx, n);
@@ -1492,7 +1492,7 @@ static void ffi_Page_run(js_State *J)
fz_page *page = js_touserdata(J, 0, "fz_page");
fz_device *device = NULL;
fz_matrix ctm = ffi_tomatrix(J, 2);
- int no_annots = js_toboolean(J, 3);
+ int no_annots = js_isdefined(J, 3) ? js_toboolean(J, 3) : 0;
if (js_isuserdata(J, 1, "fz_device")) {
device = js_touserdata(J, 1, "fz_device");
@@ -1524,7 +1524,7 @@ static void ffi_Page_toDisplayList(js_State *J)
{
fz_context *ctx = js_getcontext(J);
fz_page *page = js_touserdata(J, 0, "fz_page");
- int no_annots = js_toboolean(J, 1);
+ int no_annots = js_isdefined(J, 1) ? js_toboolean(J, 1) : 0;
fz_display_list *list;
fz_try(ctx)
@@ -1546,7 +1546,7 @@ static void ffi_Page_toPixmap(js_State *J)
fz_matrix ctm = ffi_tomatrix(J, 1);
fz_colorspace *colorspace = js_touserdata(J, 2, "fz_colorspace");
int alpha = js_toboolean(J, 3);
- int no_annots = js_toboolean(J, 4);
+ int no_annots = js_isdefined(J, 4) ? js_toboolean(J, 4) : 0;
fz_pixmap *pixmap;
fz_try(ctx)