diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-11-25 15:43:44 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-12-12 12:58:35 +0100 |
commit | 026d81043a29c6be61c22b67c01d52366151098e (patch) | |
tree | b80eabb994f0aa4254e6d164439af6cf0afcd36b /source | |
parent | b0c27de4340fdab0d5dc2b01672888bd34edc8a1 (diff) | |
download | mupdf-026d81043a29c6be61c22b67c01d52366151098e.tar.xz |
Change pdf_dict_put_val to pdf_dict_put_val_null.
It's only used to 'fix' duff indirect references when cleaning PDF
files. Writing general values into dictionaries should be done by key,
not by internal index.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-object.c | 23 | ||||
-rw-r--r-- | source/pdf/pdf-write.c | 2 |
2 files changed, 5 insertions, 20 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index f78fbadd..2b0526bd 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -1051,31 +1051,16 @@ pdf_dict_get_val(fz_context *ctx, pdf_obj *obj, int i) } void -pdf_dict_put_val(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *val) +pdf_dict_put_val_null(fz_context *ctx, pdf_obj *obj, int idx) { RESOLVE(obj); if (!OBJ_IS_DICT(obj)) fz_throw(ctx, FZ_ERROR_GENERIC, "not a dict (%s)", pdf_objkindstr(obj)); - /* FIXME: Should probably extend the dict here */ - if (i < 0 || i >= DICT(obj)->len) + if (idx < 0 || idx >= DICT(obj)->len) fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds"); - if (!val) - val = PDF_OBJ_NULL; - - pdf_drop_obj(ctx, DICT(obj)->items[i].v); - DICT(obj)->items[i].v = pdf_keep_obj(ctx, val); -} - -void -pdf_dict_put_val_drop(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *val) -{ - fz_try(ctx) - pdf_dict_put_val(ctx, obj, i, val); - fz_always(ctx) - pdf_drop_obj(ctx, val); - fz_catch(ctx) - fz_rethrow(ctx); + pdf_drop_obj(ctx, DICT(obj)->items[idx].v); + DICT(obj)->items[idx].v = PDF_OBJ_NULL; } /* Returns 0 <= i < len for key found. Returns -1-len < i <= -1 for key diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 224da50c..ae2f4122 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -608,7 +608,7 @@ static int markobj(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, pd { DEBUGGING_MARKING(indent(); printf("DICT[%d/%d] = %s\n", i, n, pdf_to_name(ctx, pdf_dict_get_key(ctx, obj, i)))); if (markobj(ctx, doc, opts, pdf_dict_get_val(ctx, obj, i))) - pdf_dict_put_val_drop(ctx, obj, i, pdf_new_null(ctx, doc)); + pdf_dict_put_val_null(ctx, obj, i); } } |