summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/pdf/pdf-object.c7
-rw-r--r--source/tools/murun.c5
2 files changed, 7 insertions, 5 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index 6f481942..f78fbadd 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -694,7 +694,12 @@ pdf_array_put(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *item)
RESOLVE(obj);
if (!OBJ_IS_ARRAY(obj))
fz_throw(ctx, FZ_ERROR_GENERIC, "not an array (%s)", pdf_objkindstr(obj));
- if (i < 0 || i >= ARRAY(obj)->len)
+ if (i == ARRAY(obj)->len)
+ {
+ pdf_array_push(ctx, obj, item);
+ return;
+ }
+ if (i < 0 || i > ARRAY(obj)->len)
fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds");
if (!item)
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 63266226..5469483a 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -2929,10 +2929,7 @@ static int ffi_pdf_obj_put(js_State *J, void *obj, const char *key)
if (is_number(key, &idx)) {
fz_try(ctx)
- if (idx == pdf_array_len(ctx, obj))
- pdf_array_push(ctx, obj, val);
- else
- pdf_array_put(ctx, obj, idx, val);
+ pdf_array_put(ctx, obj, idx, val);
fz_always(ctx)
pdf_drop_obj(ctx, val);
fz_catch(ctx)