summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/pngread.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/source/gdi/pngread.cxx')
-rw-r--r--vcl/source/gdi/pngread.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 6cf9828f682b..09bbc66b695b 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -596,6 +596,16 @@ bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint )
if ( nScansize64 > SAL_MAX_UINT32 )
return false;
+ // assume max theoretical compression of 1:1032
+ sal_uInt64 nMinSizeRequired = (nScansize64 * maOrigSize.Height()) / 1032;
+ if (nMinSizeRequired > mnStreamSize)
+ {
+ SAL_WARN("vcl.gdi", "overlarge png dimensions: " <<
+ maOrigSize.Width() << " x " << maOrigSize.Height() << " depth: " << (int)mnPngDepth <<
+ " couldn't be supplied by file length " << mnStreamSize << " at least " << nMinSizeRequired << " needed ");
+ return false;
+ }
+
mnScansize = static_cast< sal_uInt32 >( nScansize64 );
// calculate target size from original size and the preview hint