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:
markerp = cinfo.marker_list;
while (markerp != NULL) {
if (markerp->marker == JPEG_COM) {
- i_tags_add(&im->tags, "jpeg_comment", 0, markerp->data,
+ i_tags_add(&im->tags, "jpeg_comment", 0, (const char *)markerp->data,
markerp->data_length, 0);
}
#ifdef IMEXIF_ENABLE
jpeg_start_compress(&cinfo, TRUE);
if (i_tags_find(&im->tags, "jpeg_comment", 0, &comment_entry)) {
- jpeg_write_marker(&cinfo, JPEG_COM, im->tags.tags[comment_entry].data,
+ jpeg_write_marker(&cinfo, JPEG_COM,
+ (const JOCTET *)im->tags.tags[comment_entry].data,
im->tags.tags[comment_entry].size);
}