diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-12-15 17:35:32 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-12-16 09:41:05 +0100 |
commit | 0eb8fd225e16b9bb810fc3574085a2c7914df2b6 (patch) | |
tree | 2b10d34f9312a75b2c8167c55d1a60e00349d1f4 /vcl | |
parent | e9208eb0d50295ae066beeb21e0162f8858ccb25 (diff) |
tdf#138950 allow up to one short read to not trigger cancelling import
Change-Id: Iedbfc344c311c40244ba2f58c56c62ac47584028
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107788
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/filter/jpeg/JpegReader.cxx | 4 | ||||
-rw-r--r-- | vcl/source/filter/jpeg/jpeg.h | 2 | ||||
-rw-r--r-- | vcl/source/filter/jpeg/jpegc.cxx | 3 |
3 files changed, 5 insertions, 4 deletions
diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx index b0681709eb2a..80e956925c2b 100644 --- a/vcl/source/filter/jpeg/JpegReader.cxx +++ b/vcl/source/filter/jpeg/JpegReader.cxx @@ -47,7 +47,7 @@ static void init_source (j_decompress_ptr cinfo) * This is correct behavior for reading a series of images from one source. */ source->start_of_file = TRUE; - source->no_data_available = FALSE; + source->no_data_available_failures = 0; } } @@ -86,7 +86,7 @@ static boolean fill_input_buffer (j_decompress_ptr cinfo) if (!nbytes) { - source->no_data_available = TRUE; + source->no_data_available_failures++; if (source->start_of_file) /* Treat empty input file as fatal error */ { ERREXIT(cinfo, JERR_INPUT_EMPTY); diff --git a/vcl/source/filter/jpeg/jpeg.h b/vcl/source/filter/jpeg/jpeg.h index 8a8e757a9719..fb28e78ee7e2 100644 --- a/vcl/source/filter/jpeg/jpeg.h +++ b/vcl/source/filter/jpeg/jpeg.h @@ -59,7 +59,7 @@ struct SourceManagerStruct { SvStream* stream; /* source stream */ JOCTET* buffer; /* start of buffer */ boolean start_of_file; /* have we gotten any data yet? */ - boolean no_data_available; + int no_data_available_failures; }; #endif diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx index 4718ec94560c..8807927a8ebc 100644 --- a/vcl/source/filter/jpeg/jpegc.cxx +++ b/vcl/source/filter/jpeg/jpegc.cxx @@ -273,7 +273,8 @@ static void ReadJPEG(JpegStuff& rContext, JPEGReader* pJPEGReader, void* pInputS rContext.pCYMKBuffer.resize(nWidth * 4); } - for (*pLines = 0; *pLines < nHeight && !source->no_data_available; (*pLines)++) + // tdf#138950 allow up to one short read (no_data_available_failures <= 1) to not trigger cancelling import + for (*pLines = 0; *pLines < nHeight && source->no_data_available_failures <= 1; (*pLines)++) { size_t yIndex = *pLines; |