int y = 0;
while (dinfo.output_scanline < dinfo.output_height) {
jpeg_read_scanlines(&dinfo, buffer, 1);
+ if (dinfo.err->msg_code != 0) {
+ mm_util_error("jpeg_read_scanlines failed");
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto END;
+ }
+
for (i = 0; i < row_stride; i += 3) {
image[i/3] = row[i];
if (i & 1) {
while (dinfo.output_scanline < dinfo.output_height) {
/* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */
jpeg_read_scanlines(&dinfo, buffer, 1);
+ if (dinfo.err->msg_code != 0) {
+ mm_util_error("jpeg_read_scanlines failed");
+ ret = MM_UTIL_ERROR_INVALID_OPERATION;
+ goto END;
+ }
memcpy(image_buffer + state, buffer[0], row_stride);
state += row_stride;
}
ret = mm_image_create_image(dinfo.output_width, dinfo.output_height, color_format, image_buffer, image_buffer_size, decoded);
- g_free(image_buffer);
END:
+ g_free(image_buffer);
+
/* Finish decompression */
jpeg_finish_decompress(&dinfo);
mm_util_debug("jpeg_finish_decompress");