Kaydet (Commit) 28f820c1 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz: don't alloc for bitmap where there isn't enough data to fill

Change-Id: Ief236828f564ff81bf3a415127413b6cc72fd70d
üst c985cda8
......@@ -85,7 +85,13 @@ bool PBMReader::ReadPBM(Graphic & rGraphic )
// 0->PBM, 1->PGM, 2->PPM
switch ( mnMode )
{
case 0 :
case 0:
{
const size_t nRemainingSize = mrPBM.remainingSize();
const size_t nDataRequired = mnWidth * (mnHeight / 8);
if (nRemainingSize < nDataRequired)
return false;
maBmp = Bitmap( Size( mnWidth, mnHeight ), 1 );
mpAcc = maBmp.AcquireWriteAccess();
if (!mpAcc || mpAcc->Width() != mnWidth || mpAcc->Height() != mnHeight)
......@@ -94,7 +100,7 @@ bool PBMReader::ReadPBM(Graphic & rGraphic )
mpAcc->SetPaletteColor( 0, BitmapColor( 0xff, 0xff, 0xff ) );
mpAcc->SetPaletteColor( 1, BitmapColor( 0x00, 0x00, 0x00 ) );
break;
}
case 1 :
if ( mnMaxVal <= 1 )
maBmp = Bitmap( Size( mnWidth, mnHeight ), 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment