From a840253f07efe3863b874fe9bde616f09180df99 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Tue, 18 Jul 2006 14:34:52 +0000 Subject: [PATCH] make the selection of a transfer function check that it's getting the right number of channels --- jpeg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jpeg.c b/jpeg.c index 1215fa0c..90573b7a 100644 --- a/jpeg.c +++ b/jpeg.c @@ -427,11 +427,25 @@ i_readjpeg_wiol(io_glue *data, int length, char** iptc_itext, int *itlength) { channels = cinfo.output_components; switch (cinfo.out_color_space) { case JCS_GRAYSCALE: + if (cinfo.output_components != 1) { + mm_log((1, "i_readjpeg: grayscale image with %d channels\n", cinfo.output_components)); + i_push_errorf(0, "grayscale image with invalid components %d", cinfo.output_components); + wiol_term_source(&cinfo); + jpeg_destroy_decompress(&cinfo); + return NULL; + } transfer_f = transfer_gray; break; case JCS_RGB: transfer_f = transfer_rgb; + if (cinfo.output_components != 3) { + mm_log((1, "i_readjpeg: RGB image with %d channels\n", cinfo.output_components)); + i_push_errorf(0, "RGB image with invalid components %d", cinfo.output_components); + wiol_term_source(&cinfo); + jpeg_destroy_decompress(&cinfo); + return NULL; + } break; case JCS_CMYK: -- 2.39.5