]> git.imager.perl.org - imager.git/commitdiff
make the selection of a transfer function check that it's getting the
authorTony Cook <tony@develop=help.com>
Tue, 18 Jul 2006 14:34:52 +0000 (14:34 +0000)
committerTony Cook <tony@develop=help.com>
Tue, 18 Jul 2006 14:34:52 +0000 (14:34 +0000)
right number of channels

jpeg.c

diff --git a/jpeg.c b/jpeg.c
index 1215fa0c08e357972e120ac907dc792452c80eca..90573b7ae7716e642ccbf5b875111cdb71bd3d3c 100644 (file)
--- 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: