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

check stream state more often for failures

Change-Id: Ie45d858021c3123ec21829cbf4742cf30ce46665
üst 23a0fe78
...@@ -54,7 +54,7 @@ private: ...@@ -54,7 +54,7 @@ private:
bool ImplReadBody(BitmapWriteAccess * pAcc); bool ImplReadBody(BitmapWriteAccess * pAcc);
bool ImplReadHeader(); bool ImplReadHeader();
sal_uInt8 ImplGetByte(); sal_uInt8 ImplGetByte();
public: public:
RASReader(SvStream &rRAS); RASReader(SvStream &rRAS);
...@@ -174,13 +174,11 @@ bool RASReader::ReadRAS(Graphic & rGraphic) ...@@ -174,13 +174,11 @@ bool RASReader::ReadRAS(Graphic & rGraphic)
return mbStatus; return mbStatus;
} }
bool RASReader::ImplReadHeader() bool RASReader::ImplReadHeader()
{ {
m_rRAS.ReadInt32(mnWidth).ReadInt32(mnHeight).ReadInt32(mnDepth).ReadInt32(mnImageDatSize).ReadInt32(mnType).ReadInt32(mnColorMapType).ReadInt32(mnColorMapSize); m_rRAS.ReadInt32(mnWidth).ReadInt32(mnHeight).ReadInt32(mnDepth).ReadInt32(mnImageDatSize).ReadInt32(mnType).ReadInt32(mnColorMapType).ReadInt32(mnColorMapSize);
if ( mnWidth <= 0 || mnHeight <= 0 || mnImageDatSize <= 0 ) if (mnWidth <= 0 || mnHeight <= 0 || mnImageDatSize <= 0 || !m_rRAS.good())
mbStatus = false; mbStatus = false;
switch ( mnDepth ) switch ( mnDepth )
...@@ -222,7 +220,7 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -222,7 +220,7 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
switch ( mnDstBitsPerPix ) switch ( mnDstBitsPerPix )
{ {
case 1 : case 1 :
for ( y = 0; y < mnHeight; y++ ) for (y = 0; y < mnHeight && mbStatus; ++y)
{ {
for ( x = 0; x < mnWidth; x++ ) for ( x = 0; x < mnWidth; x++ )
{ {
...@@ -233,11 +231,13 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -233,11 +231,13 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
nDat >> ( ( x & 7 ) ^ 7 )) ); nDat >> ( ( x & 7 ) ^ 7 )) );
} }
if (!( ( x - 1 ) & 0x8 ) ) ImplGetByte(); // WORD ALIGNMENT ??? if (!( ( x - 1 ) & 0x8 ) ) ImplGetByte(); // WORD ALIGNMENT ???
if (!m_rRAS.good())
mbStatus = false;
} }
break; break;
case 8 : case 8 :
for ( y = 0; y < mnHeight; y++ ) for (y = 0; y < mnHeight && mbStatus; ++y)
{ {
for ( x = 0; x < mnWidth; x++ ) for ( x = 0; x < mnWidth; x++ )
{ {
...@@ -245,6 +245,8 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -245,6 +245,8 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
pAcc->SetPixelIndex( y, x, nDat ); pAcc->SetPixelIndex( y, x, nDat );
} }
if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ??? if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ???
if (!m_rRAS.good())
mbStatus = false;
} }
break; break;
...@@ -253,7 +255,7 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -253,7 +255,7 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
{ {
case 24 : case 24 :
for ( y = 0; y < mnHeight; y++ ) for (y = 0; y < mnHeight && mbStatus; ++y)
{ {
for ( x = 0; x < mnWidth; x++ ) for ( x = 0; x < mnWidth; x++ )
{ {
...@@ -272,11 +274,13 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -272,11 +274,13 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
pAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) ); pAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) );
} }
if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ??? if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ???
if (!m_rRAS.good())
mbStatus = false;
} }
break; break;
case 32 : case 32 :
for ( y = 0; y < mnHeight; y++ ) for (y = 0; y < mnHeight && mbStatus; ++y)
{ {
for ( x = 0; x < mnWidth; x++ ) for ( x = 0; x < mnWidth; x++ )
{ {
...@@ -295,6 +299,8 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -295,6 +299,8 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
} }
pAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) ); pAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) );
} }
if (!m_rRAS.good())
mbStatus = false;
} }
break; break;
} }
...@@ -307,8 +313,6 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc) ...@@ -307,8 +313,6 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
return mbStatus; return mbStatus;
} }
sal_uInt8 RASReader::ImplGetByte() sal_uInt8 RASReader::ImplGetByte()
{ {
sal_uInt8 nRetVal; sal_uInt8 nRetVal;
......
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