summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-10-16 15:01:03 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-10-25 15:50:27 +0200
commite815e64406e574a75a33e057f954422d56ade314 (patch)
tree60e0698de2155ab063173ac3885266434e13c2c8 /source
parentc7535ca8ef92af5adcb58d1b33e15933c27951c5 (diff)
downloadmupdf-e815e64406e574a75a33e057f954422d56ade314.tar.xz
Guard loading embedded ICC profiles in images with FZ_ENABLE_ICC.
Stops all the extra errors and warnings about missing ICC support.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/load-gif.c9
-rw-r--r--source/fitz/load-jpeg.c4
-rw-r--r--source/fitz/load-jpx.c4
-rw-r--r--source/fitz/load-png.c2
-rw-r--r--source/fitz/load-tiff.c2
5 files changed, 19 insertions, 2 deletions
diff --git a/source/fitz/load-gif.c b/source/fitz/load-gif.c
index b94763ba..b61428f6 100644
--- a/source/fitz/load-gif.c
+++ b/source/fitz/load-gif.c
@@ -357,6 +357,7 @@ gif_read_pte(fz_context *ctx, struct info *info, const unsigned char *p, const u
static const unsigned char *
gif_read_icc(fz_context *ctx, struct info *info, const unsigned char *p, const unsigned char *end)
{
+#if FZ_ENABLE_ICC
fz_colorspace *cs = NULL;
fz_stream *bstm = NULL;
fz_pixmap *newpix;
@@ -367,9 +368,10 @@ gif_read_icc(fz_context *ctx, struct info *info, const unsigned char *p, const u
fz_var(bstm);
fz_var(cs);
+ p = gif_read_subblocks(ctx, info, p, end, icc);
+
fz_try(ctx)
{
- p = gif_read_subblocks(ctx, info, p, end, icc);
bstm = fz_open_buffer(ctx, icc);
cs = fz_new_icc_colorspace_from_stream(ctx, FZ_COLORSPACE_NONE, bstm);
@@ -388,10 +390,13 @@ gif_read_icc(fz_context *ctx, struct info *info, const unsigned char *p, const u
}
fz_catch(ctx)
{
- fz_rethrow(ctx);
+ fz_warn(ctx, "cannot read embedded ICC profile");
}
return p;
+#else
+ return gif_read_subblocks(ctx, info, p, end, NULL);
+#endif
}
/*
diff --git a/source/fitz/load-jpeg.c b/source/fitz/load-jpeg.c
index 1c4036cd..675fafd7 100644
--- a/source/fitz/load-jpeg.c
+++ b/source/fitz/load-jpeg.c
@@ -122,6 +122,7 @@ enum {
static fz_colorspace *extract_icc_profile(fz_context *ctx, jpeg_saved_marker_ptr init_marker)
{
+#if FZ_ENABLE_ICC
const char idseq[] = { 'I', 'C', 'C', '_', 'P', 'R', 'O', 'F', 'I', 'L', 'E', '\0'};
jpeg_saved_marker_ptr marker = init_marker;
fz_buffer *buf = NULL;
@@ -184,6 +185,9 @@ static fz_colorspace *extract_icc_profile(fz_context *ctx, jpeg_saved_marker_ptr
fz_warn(ctx, "could not load ICC profile in JPEG image");
return cs;
+#else
+ return NULL;
+#endif
}
static int extract_exif_resolution(jpeg_saved_marker_ptr marker, int *xres, int *yres)
diff --git a/source/fitz/load-jpx.c b/source/fitz/load-jpx.c
index 2a15d185..07491733 100644
--- a/source/fitz/load-jpx.c
+++ b/source/fitz/load-jpx.c
@@ -312,6 +312,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, const unsigned char *data, size_
}
}
+#if FZ_ENABLE_ICC
if (!state->cs && colorspace == cJP2_Colorspace_Palette_ICCa)
{
unsigned char *iccprofile = NULL;
@@ -335,6 +336,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, const unsigned char *data, size_
fz_warn(ctx, "cannot load ICC profile: %s", fz_caught_message(ctx));
}
}
+#endif
if (!state->cs)
{
@@ -784,6 +786,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, const unsigned char *data, size_
}
}
+#if FZ_ENABLE_ICC
if (!state->cs && jpx->icc_profile_buf)
{
fz_stream *cstm = NULL;
@@ -801,6 +804,7 @@ jpx_read_image(fz_context *ctx, fz_jpxd *state, const unsigned char *data, size_
fz_warn(ctx, "cannot load ICC profile: %s", fz_caught_message(ctx));
}
}
+#endif
if (!state->cs)
{
diff --git a/source/fitz/load-png.c b/source/fitz/load-png.c
index fbda9035..7d2201ee 100644
--- a/source/fitz/load-png.c
+++ b/source/fitz/load-png.c
@@ -344,6 +344,7 @@ png_read_trns(fz_context *ctx, struct info *info, const unsigned char *p, unsign
static void
png_read_icc(fz_context *ctx, struct info *info, const unsigned char *p, unsigned int size)
{
+#if FZ_ENABLE_ICC
fz_stream *mstm = NULL, *zstm = NULL;
fz_colorspace *cs = NULL;
size_t m = fz_mini(80, size);
@@ -373,6 +374,7 @@ png_read_icc(fz_context *ctx, struct info *info, const unsigned char *p, unsigne
}
fz_catch(ctx)
fz_warn(ctx, "cannot read embedded ICC profile");
+#endif
}
static void
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index 6e903e66..0e58859d 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -1134,6 +1134,7 @@ tiff_decode_ifd(fz_context *ctx, struct tiff *tiff)
tiff->stride = (tiff->imagewidth * tiff->samplesperpixel * tiff->bitspersample + 7) / 8;
tiff->tilestride = (tiff->tilewidth * tiff->samplesperpixel * tiff->bitspersample + 7) / 8;
+#if FZ_ENALBE_ICC
if (tiff->profile)
{
fz_buffer *buff = NULL;
@@ -1152,6 +1153,7 @@ tiff_decode_ifd(fz_context *ctx, struct tiff *tiff)
tiff->colorspace = NULL;
}
}
+#endif
if (tiff->colorspace == NULL)
{