From: Tony Cook <tony@develop=help.com> Date: Tue, 18 Jul 2006 14:34:52 +0000 (+0000) Subject: make the selection of a transfer function check that it's getting the X-Git-Tag: Imager-0.52~13 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/a840253f07efe3863b874fe9bde616f09180df99 make the selection of a transfer function check that it's getting the right number of channels --- 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: