Fixed overflow situation

This commit is contained in:
Laurence Bank 2021-08-31 16:24:27 +01:00
parent 68654e70a9
commit 2bc29c766b

View File

@ -1028,6 +1028,11 @@ static void jpeg_check_highwater(jpeg_buf_t *jpeg_buf)
if (jpeg_buf->realloc == false) {
// Can't realloc buffer
jpeg_buf->overflow = true;
// Reset length so that the next data writes won't go past
// the end of the existing buffer. This will allow the encode
// to finish and the overflow flag will show the caller that
// there was a failure due to too small an output buffer.
jpeg_buf->length = 0;
return;
}
jpeg_buf->length += 1024;