ofz#17817 avoid OOM

Change-Id: I354edf5b169e797c76ec79719cdce01e63329df4
Reviewed-on: https://gerrit.libreoffice.org/79833
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara 2019-09-30 09:35:23 +01:00
parent 227734f528
commit f78090e3d5

View File

@ -711,9 +711,15 @@ namespace emfio
bool bOk = nWidth && nHeight && nPlanes == 1 && nBitCount == 1 && nBytesPerScan != 0;
if (bOk)
{
// must be enough data to fulfil the request
bOk = nBytesPerScan <= mpInputStream->remainingSize() / nHeight;
}
if (bOk)
{
// scanline must be large enough to provide all pixels
bOk = nBytesPerScan >= nWidth / 8;
}
if (bOk)
{
vcl::bitmap::RawBitmap aBmp( Size( nWidth, nHeight ), 24 );
for (sal_uInt16 y = 0; y < nHeight && mpInputStream->good(); ++y)