diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2012-07-19 00:41:04 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2012-07-23 18:07:03 +0200 |
commit | e61ff8e87edaee5c3b1a85b7d08bd2c7ed2ecb38 (patch) | |
tree | ef4f89d969df170160b43b5af4d6d8a88d9b7f8d /pdf/pdf_function.c | |
parent | 4b7929c79941d2835bac62e7a80d14e297db6c12 (diff) | |
download | mupdf-e61ff8e87edaee5c3b1a85b7d08bd2c7ed2ecb38.tar.xz |
Provide number of inputs/outpus when loading pdf functions
This will allow the loading of pdf functions to validate that a pdf
function has the correct number of inputs/outputs. Additionally it
will allow for handling pdf functions with incorrect number of
inputs/outputs.
Diffstat (limited to 'pdf/pdf_function.c')
-rw-r--r-- | pdf/pdf_function.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index 2152ae05..978f2473 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -1229,7 +1229,7 @@ load_stitching_func(pdf_function *func, pdf_document *xref, pdf_obj *dict) for (i = 0; i < k; i++) { sub = pdf_array_get(obj, i); - funcs[i] = pdf_load_function(xref, sub); + funcs[i] = pdf_load_function(xref, sub, 1, func->n); /* RJW: "cannot load sub function %d (%d %d R)", i, pdf_to_num(sub), pdf_to_gen(sub) */ if (funcs[i]->m != 1 || funcs[i]->n != funcs[0]->n) fz_throw(ctx, "sub function %d /Domain or /Range mismatch", i); @@ -1237,9 +1237,7 @@ load_stitching_func(pdf_function *func, pdf_document *xref, pdf_obj *dict) func->u.st.k ++; } - if (!func->n) - func->n = funcs[0]->n; - else if (func->n != funcs[0]->n) + if (func->n != funcs[0]->n) fz_throw(ctx, "sub function /Domain or /Range mismatch"); } @@ -1371,7 +1369,7 @@ pdf_function_size(pdf_function *func) } pdf_function * -pdf_load_function(pdf_document *xref, pdf_obj *dict) +pdf_load_function(pdf_document *xref, pdf_obj *dict, int in, int out) { fz_context *ctx = xref->ctx; pdf_function *func; @@ -1414,9 +1412,14 @@ pdf_load_function(pdf_document *xref, pdf_obj *dict) else { func->has_range = 0; - func->n = 0; + func->n = out; } + if (func->m != in) + fz_warn(ctx, "too few/many function inputs"); + if (func->n != out) + fz_warn(ctx, "too few/many function outputs"); + fz_try(ctx) { switch(func->type) |