{
struct jpeg_destination_mgr * dest = state->cinfo->dest;
+ dest->free_in_buffer = state->free_in_buffer;
+
if (! (*dest->empty_output_buffer) (state->cinfo))
return FALSE;
/* After a successful buffer dump, must reset buffer pointers */
unsigned char *buffer;
int put_buffer, put_bits;
- if ((state)->free_in_buffer < DCTSIZE2 * 2)
+ if ((state)->free_in_buffer < 1)
if (! dump_buffer(state)) return FALSE;
+ if ((state)->free_in_buffer < 1)
+ ERREXIT(state->cinfo, JERR_BUFFER_SIZE);
buffer = state->next_output_byte;
put_buffer = state->cur.put_buffer;
state->free_in_buffer -= (buffer - state->next_output_byte);
state->next_output_byte = buffer;
- if ((state)->free_in_buffer < DCTSIZE2 * 2)
- if (! dump_buffer(state)) return FALSE;
-
return TRUE;
}
if ((state)->free_in_buffer < DCTSIZE2 * 2)
if (! dump_buffer(state)) return FALSE;
+ if ((state)->free_in_buffer < DCTSIZE2 * 2)
+ ERREXIT(state->cinfo, JERR_BUFFER_SIZE);
buffer = state->next_output_byte;
put_buffer = state->cur.put_buffer;
state->free_in_buffer -= (buffer - state->next_output_byte);
state->next_output_byte = buffer;
- if ((state)->free_in_buffer < DCTSIZE2 * 2)
- if (! dump_buffer(state)) return FALSE;
-
return TRUE;
}
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
- if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
- (size_t) OUTPUT_BUF_SIZE)
+ if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE
+ - dest->pub.free_in_buffer) !=
+ (size_t) (OUTPUT_BUF_SIZE - dest->pub.free_in_buffer))
ERREXIT(cinfo, JERR_FILE_WRITE);
dest->pub.next_output_byte = dest->buffer;