diff --git a/cderror.h b/cderror.h index 77b8eb64..e7ac9d99 100644 --- a/cderror.h +++ b/cderror.h @@ -127,6 +127,8 @@ JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") JMESSAGE(JERR_PNG_ERROR, "Unable to read PNG file: %s") #endif +JMESSAGE(JERR_UNSUPPORTED_SUSPEND, "I/O suspension not supported in scan optimization") + #ifdef JMAKE_ENUM_LIST JMSG_LASTADDONCODE diff --git a/jcmaster.c b/jcmaster.c index bf5bf2f5..938e058b 100644 --- a/jcmaster.c +++ b/jcmaster.c @@ -605,7 +605,9 @@ copy_buffer (j_compress_ptr cinfo, int scan_idx) size -= cinfo->dest->free_in_buffer; cinfo->dest->next_output_byte += cinfo->dest->free_in_buffer; cinfo->dest->free_in_buffer = 0; - (*cinfo->dest->empty_output_buffer)(cinfo); + + if (!(*cinfo->dest->empty_output_buffer)(cinfo)) + ERREXIT(cinfo, JERR_UNSUPPORTED_SUSPEND); } MEMCOPY(cinfo->dest->next_output_byte, src, size);