summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-05-23 13:02:45 +0200
committerRobin Watts <robin.watts@artifex.com>2016-05-24 13:22:47 +0100
commit9245cd0d2e353262ba518fb9f2e950bb74ad3c3e (patch)
tree0cd38bfa5085183b5433f9c16314994cb0cf7330 /source/pdf
parentb18626a2f5aa61be3173341271243a5ad7922799 (diff)
downloadmupdf-9245cd0d2e353262ba518fb9f2e950bb74ad3c3e.tar.xz
Fix 696796: clamp color values in PDF to valid range.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-op-filter.c4
-rw-r--r--source/pdf/pdf-op-run.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/source/pdf/pdf-op-filter.c b/source/pdf/pdf-op-filter.c
index a8496e35..8eebe5cd 100644
--- a/source/pdf/pdf-op-filter.c
+++ b/source/pdf/pdf-op-filter.c
@@ -929,7 +929,7 @@ pdf_filter_SC_color(fz_context *ctx, pdf_processor *proc, int n, float *color)
gstate->SC.shd = NULL;
gstate->SC.n = n;
for (i = 0; i < n; ++i)
- gstate->SC.c[i] = color[i];
+ gstate->SC.c[i] = fz_clamp(color[i], 0, 1);
}
static void
@@ -943,7 +943,7 @@ pdf_filter_sc_color(fz_context *ctx, pdf_processor *proc, int n, float *color)
gstate->sc.shd = NULL;
gstate->sc.n = n;
for (i = 0; i < n; ++i)
- gstate->sc.c[i] = color[i];
+ gstate->sc.c[i] = fz_clamp(color[i], 0, 1);
}
static void
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index 012b5054..e502cf69 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -1138,11 +1138,11 @@ pdf_set_color(fz_context *ctx, pdf_run_processor *pr, int what, float *v)
case PDF_MAT_COLOR:
if (fz_colorspace_is_indexed(ctx, mat->colorspace))
{
- mat->v[0] = v[0] / 255;
+ mat->v[0] = fz_clamp(v[0], 0, 1) / 255;
break;
}
for (i = 0; i < mat->colorspace->n; i++)
- mat->v[i] = v[i];
+ mat->v[i] = fz_clamp(v[i], 0, 1);
break;
default:
fz_warn(ctx, "color incompatible with material");