[Libreoffice-commits] core.git: 2 commits - editeng/qa vcl/source
Caolán McNamara
caolanm at redhat.com
Fri Mar 10 14:54:41 UTC 2017
editeng/qa/unit/core-test.cxx | 3 +++
vcl/source/filter/jpeg/JpegReader.cxx | 13 +++----------
vcl/source/filter/jpeg/jpeg.h | 11 +++++++++++
vcl/source/filter/jpeg/jpegc.cxx | 3 ++-
4 files changed, 19 insertions(+), 11 deletions(-)
New commits:
commit d7685eb3f417e19a5e61f2fe550eb03d6848365d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Mar 10 14:53:47 2017 +0000
ensure SfxApplication exists for editeng test
Change-Id: I73814e38437f83f8aa7b87addc285e82f7357bea
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 23defaa..dea52f3 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -12,6 +12,7 @@
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
+#include "sfx2/app.hxx"
#include "svl/itempool.hxx"
#include "editeng/eerdll.hxx"
#include "editeng/eerdll2.hxx"
@@ -80,6 +81,8 @@ void Test::setUp()
test::BootstrapFixture::setUp();
mpItemPool = new EditEngineItemPool(true);
+
+ SfxApplication::GetOrCreate();
}
void Test::tearDown()
commit f596e5d461b6436cdb6ee9efa59807d99bb54135
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Mar 10 14:04:59 2017 +0000
ofz#799 stop decompressing if the file is truncated
Change-Id: I4040ebbf7b21905b950f4af36012bc83aebaa320
diff --git a/vcl/source/filter/jpeg/JpegReader.cxx b/vcl/source/filter/jpeg/JpegReader.cxx
index cde54c4..7cd9a22 100644
--- a/vcl/source/filter/jpeg/JpegReader.cxx
+++ b/vcl/source/filter/jpeg/JpegReader.cxx
@@ -33,15 +33,6 @@
#define JPEG_MIN_READ 512
#define BUFFER_SIZE 4096
-/* Expanded data source object for stdio input */
-
-struct SourceManagerStruct {
- jpeg_source_mgr pub; /* public fields */
- SvStream* stream; /* source stream */
- JOCTET* buffer; /* start of buffer */
- boolean start_of_file; /* have we gotten any data yet? */
-};
-
/*
* Initialize source --- called by jpeg_read_header
* before any data is actually read.
@@ -55,6 +46,7 @@ extern "C" 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;
}
long StreamRead( SvStream* pStream, void* pBuffer, long nBufferSize )
@@ -89,6 +81,7 @@ extern "C" boolean fill_input_buffer (j_decompress_ptr cinfo)
if (!nbytes)
{
+ source->no_data_available = TRUE;
if (source->start_of_file) /* Treat empty input file as fatal error */
{
ERREXIT(cinfo, JERR_INPUT_EMPTY);
@@ -158,7 +151,7 @@ void jpeg_svstream_src (j_decompress_ptr cinfo, void* input)
(*cinfo->mem->alloc_small) (reinterpret_cast<j_common_ptr>(cinfo), JPOOL_PERMANENT, BUFFER_SIZE * sizeof(JOCTET)));
}
- source = reinterpret_cast<SourceManagerStruct *>(cinfo->src);
+ source = reinterpret_cast<SourceManagerStruct*>(cinfo->src);
source->pub.init_source = init_source;
source->pub.fill_input_buffer = fill_input_buffer;
source->pub.skip_input_data = skip_input_data;
diff --git a/vcl/source/filter/jpeg/jpeg.h b/vcl/source/filter/jpeg/jpeg.h
index 08caa47..1927663 100644
--- a/vcl/source/filter/jpeg/jpeg.h
+++ b/vcl/source/filter/jpeg/jpeg.h
@@ -34,6 +34,7 @@ namespace com { namespace sun { namespace star { namespace task {
class JPEGReader;
class JPEGWriter;
class Size;
+class SvStream;
void jpeg_svstream_src (j_decompress_ptr cinfo, void* infile);
@@ -49,6 +50,16 @@ void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
long Transform( void* pInputStream, void* pOutputStream, long nAngle );
+/* Expanded data source object for stdio input */
+
+struct SourceManagerStruct {
+ jpeg_source_mgr pub; /* public fields */
+ SvStream* stream; /* source stream */
+ JOCTET* buffer; /* start of buffer */
+ boolean start_of_file; /* have we gotten any data yet? */
+ boolean no_data_available;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx
index 8fc0ed8..a5f1edb 100644
--- a/vcl/source/filter/jpeg/jpegc.cxx
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -84,6 +84,7 @@ void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
jpeg_create_decompress( &cinfo );
jpeg_svstream_src( &cinfo, pInputStream );
+ SourceManagerStruct *source = reinterpret_cast<SourceManagerStruct*>(cinfo.src);
jpeg_read_header( &cinfo, TRUE );
cinfo.scale_num = 1;
@@ -190,7 +191,7 @@ void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
}
}
- for (*pLines = 0; *pLines < nHeight; (*pLines)++)
+ for (*pLines = 0; *pLines < nHeight && !source->no_data_available; (*pLines)++)
{
size_t yIndex = *pLines;
More information about the Libreoffice-commits
mailing list