summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2012-09-29 02:08:15 +0200
committerRobin Watts <robin.watts@artifex.com>2012-10-01 12:35:27 +0100
commit4b0a8e2a428e38b5084e1f8d678495adbbc61504 (patch)
treee2e1b9061c63d187bae66a847ac5e1cbf3035385
parentf49092b41ae75b0ee15bb933eb093825a5d5de4b (diff)
downloadmupdf-4b0a8e2a428e38b5084e1f8d678495adbbc61504.tar.xz
Give better warnings for out of bounds values in shadings
-rw-r--r--pdf/pdf_shade.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c
index 6fbfd6b7..24ccde6e 100644
--- a/pdf/pdf_shade.c
+++ b/pdf/pdf_shade.c
@@ -190,6 +190,7 @@ struct mesh_params
static void
pdf_load_mesh_params(fz_shade *shade, pdf_document *xref, pdf_obj *dict)
{
+ fz_context *ctx = xref->ctx;
pdf_obj *obj;
int i, n;
@@ -221,20 +222,33 @@ pdf_load_mesh_params(fz_shade *shade, pdf_document *xref, pdf_obj *dict)
}
}
- if (shade->u.m.vprow < 2)
+ if (shade->u.m.vprow < 2 && shade->type == 5)
+ {
+ fz_warn(ctx, "Too few vertices per row (%d)", shade->u.m.vprow);
shade->u.m.vprow = 2;
+ }
- if (shade->u.m.bpflag != 2 && shade->u.m.bpflag != 4 && shade->u.m.bpflag != 8)
+ if (shade->u.m.bpflag != 2 && shade->u.m.bpflag != 4 && shade->u.m.bpflag != 8 &&
+ shade->type != 5)
+ {
+ fz_warn(ctx, "Invalid number of bits per flag (%d)", shade->u.m.bpflag);
shade->u.m.bpflag = 8;
+ }
if (shade->u.m.bpcoord != 1 && shade->u.m.bpcoord != 2 && shade->u.m.bpcoord != 4 &&
shade->u.m.bpcoord != 8 && shade->u.m.bpcoord != 12 && shade->u.m.bpcoord != 16 &&
shade->u.m.bpcoord != 24 && shade->u.m.bpcoord != 32)
+ {
+ fz_warn(ctx, "Invalid number of bits per coordinate (%d)", shade->u.m.bpcoord);
shade->u.m.bpcoord = 8;
+ }
if (shade->u.m.bpcomp != 1 && shade->u.m.bpcomp != 2 && shade->u.m.bpcomp != 4 &&
shade->u.m.bpcomp != 8 && shade->u.m.bpcomp != 12 && shade->u.m.bpcomp != 16)
+ {
+ fz_warn(ctx, "Invalid number of bits per component (%d)", shade->u.m.bpcomp);
shade->u.m.bpcomp = 8;
+ }
}
static void