summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-10-16 15:43:17 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-10-25 22:11:54 +0200
commita101366eeb06d375b32d96f305bce5bc131f7b03 (patch)
tree8b4994ced5e218ef93df327da3a0e2e14b2c440c /source
parentf036f9efde139a8127b04ac32caeb9836c0ecabb (diff)
downloadmupdf-a101366eeb06d375b32d96f305bce5bc131f7b03.tar.xz
Fix asserts and checks in fast_xxx_to_yyy functions.
fast_rgb_to_cmyk had || instead of && so always triggered incorrectly. Only throw, no need to both assert and throw.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/colorspace.c90
1 files changed, 40 insertions, 50 deletions
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 89bef0aa..80d15157 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -953,11 +953,10 @@ static void fast_gray_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
ptrdiff_t s_line_inc = src->stride - w * sn;
/* If copying spots, they must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1088,11 +1087,10 @@ static void fast_gray_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, f
ptrdiff_t s_line_inc = src->stride - w * sn;
/* If copying spots, they must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1228,11 +1226,10 @@ static void fast_rgb_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
ptrdiff_t s_line_inc = src->stride - w * sn;
/* If copying spots, they must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1353,11 +1350,10 @@ static void fast_bgr_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
ptrdiff_t s_line_inc = src->stride - w * sn;
/* If copying spots, they must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1481,11 +1477,10 @@ static void fast_rgb_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
ptrdiff_t s_line_inc = src->stride - w * sn;
/* Spots must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots || ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1641,11 +1636,10 @@ static void fast_bgr_to_cmyk(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
ptrdiff_t s_line_inc = src->stride - w * sn;
/* Spots must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1801,11 +1795,10 @@ static void fast_cmyk_to_gray(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, f
ptrdiff_t s_line_inc = src->stride - w * sn;
/* Spots must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -1943,11 +1936,10 @@ static void fast_cmyk_to_rgb(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
unsigned char r,g,b;
/* Spots must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -2089,11 +2081,10 @@ static void fast_cmyk_to_bgr(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz
unsigned char r,g,b;
/* Spots must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;
@@ -2236,11 +2227,10 @@ static void fast_rgb_to_bgr(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src, fz_
ptrdiff_t s_line_inc = src->stride - w * sn;
/* If copying spots, they must match, and we can never drop alpha (but we can invent it) */
- if ((copy_spots && ss != ds) || (!da && sa))
- {
- assert("This should never happen" == NULL);
- fz_throw(ctx, FZ_ERROR_GENERIC, "Cannot convert between incompatible pixmaps");
- }
+ if (copy_spots && ss != ds)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "incompatible number of spots when converting pixmap");
+ if (!da && sa)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot drop alpha when converting pixmap");
if ((int)w < 0 || h < 0)
return;