From 15fc25b0055dbdbfaf4257ac908d43fd5a2da19d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 4 Jul 2012 16:12:02 +0100 Subject: Cope with stray returns at the start of a JPEG stream. Acrobat seems to cope, we should too. See normal_439.pdf for an example. --- fitz/filt_dctd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fitz') diff --git a/fitz/filt_dctd.c b/fitz/filt_dctd.c index 23744f01..1b588d2a 100644 --- a/fitz/filt_dctd.c +++ b/fitz/filt_dctd.c @@ -101,12 +101,17 @@ read_dctd(fz_stream *stm, unsigned char *buf, int len) if (!state->init) { + int c; cinfo->client_data = state; cinfo->err = &state->errmgr; jpeg_std_error(cinfo->err); cinfo->err->error_exit = error_exit; jpeg_create_decompress(cinfo); + /* Skip over any stray returns at the start of the stream */ + while ((c = fz_peek_byte(state->chain)) == '\n' || c == '\r') + (void)fz_read_byte(state->chain); + cinfo->src = &state->srcmgr; cinfo->src->init_source = init_source; cinfo->src->fill_input_buffer = fill_input_buffer; -- cgit v1.2.3