summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-02-13 14:32:30 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-02-13 14:37:38 +0000
commit7c9c6a4425b679596acae6f67ee8ac5f3d98bd6e (patch)
tree7648f0fe3847c3e24dff5aca8583a72b63d751b8 /filter
parentec7cc3e529740384735f7c396461cc16d419f874 (diff)
ofz: move size check before bitmap allocation
Change-Id: I09deab103a3bc53277ea3d545b2737438875dfc5
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/ipcx/ipcx.cxx26
1 files changed, 10 insertions, 16 deletions
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
index 4bb500d66859..8ded909962c7 100644
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ b/filter/source/graphicfilter/ipcx/ipcx.cxx
@@ -90,8 +90,14 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
ImplReadHeader();
+ // sanity check there is enough data before trying allocation
+ if (bStatus && nBytesPerPlaneLin > m_rPCX.remainingSize() / nPlanes)
+ {
+ bStatus = false;
+ }
+
// Write BMP header and conditionally (maybe invalid for now) color palette:
- if ( bStatus )
+ if (bStatus)
{
aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel );
Bitmap::ScopedWriteAccess pAcc(aBmp);
@@ -108,6 +114,7 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
pAcc->SetPaletteColor( i, BitmapColor ( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] ) );
}
}
+
// read bitmap data
ImplReadBody(pAcc.get());
@@ -124,14 +131,8 @@ bool PCXReader::ReadPCX(Graphic & rGraphic)
pAcc->SetPaletteColor( i, BitmapColor ( pPal[ 0 ], pPal[ 1 ], pPal[ 2 ] ) );
}
}
- /*
- // set resolution:
- if (nResX!=0 && nResY!=0) {
- MapMode aMapMode(MapUnit::MapInch,Point(0,0),Fraction(1,nResX),Fraction(1,nResY));
- rBitmap.SetPrefMapMode(aMapMode);
- rBitmap.SetPrefSize(Size(nWidth,nHeight));
- }
- */ if ( bStatus )
+
+ if ( bStatus )
{
rGraphic = aBmp;
return true;
@@ -206,13 +207,6 @@ void PCXReader::ImplReadBody(BitmapWriteAccess * pAcc)
sal_uLong nLastPercent = 0;
sal_uInt8 nDat = 0, nCol = 0;
- //sanity check there is enough data before trying allocation
- if (nBytesPerPlaneLin > m_rPCX.remainingSize() / nPlanes)
- {
- bStatus = false;
- return;
- }
-
for( np = 0; np < nPlanes; np++ )
pPlane[ np ] = new sal_uInt8[ nBytesPerPlaneLin ];