[Libreoffice-commits] core.git: filter/source

Caolán McNamara caolanm at redhat.com
Thu Mar 2 10:57:27 UTC 2017


 filter/source/graphicfilter/ipbm/ipbm.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 28f820c1a0d8bbe7705d6c43a7c5c4a98bef0cbd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 2 10:56:05 2017 +0000

    ofz: don't alloc for bitmap where there isn't enough data to fill
    
    Change-Id: Ief236828f564ff81bf3a415127413b6cc72fd70d

diff --git a/filter/source/graphicfilter/ipbm/ipbm.cxx b/filter/source/graphicfilter/ipbm/ipbm.cxx
index 13241aa..aeb974c 100644
--- a/filter/source/graphicfilter/ipbm/ipbm.cxx
+++ b/filter/source/graphicfilter/ipbm/ipbm.cxx
@@ -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);


More information about the Libreoffice-commits mailing list