summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-09-11 15:38:01 +0100
committerAndras Timar <andras.timar@collabora.com>2015-09-19 21:32:13 +0200
commit0237c15b2de17a715df9f6e15c97a72c22621f72 (patch)
treefd22f410057e1423d129a576010f6f4d69b75bac
parent8a8074a7f1658b5489ef1510fb2a00277dc88cd2 (diff)
check stream status more often
Change-Id: I233c2fff9c06a81117f8114ccee83b53ea4026db (cherry picked from commit b43e03353aeb04ed74a272d98df03dd7c20f3478) Reviewed-on: https://gerrit.libreoffice.org/18505 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: David Tardon <dtardon@redhat.com>
-rw-r--r--filter/qa/cppunit/data/ras/fail/hang-1.rasbin0 -> 40 bytes
-rw-r--r--filter/source/graphicfilter/iras/iras.cxx47
2 files changed, 32 insertions, 15 deletions
diff --git a/filter/qa/cppunit/data/ras/fail/hang-1.ras b/filter/qa/cppunit/data/ras/fail/hang-1.ras
new file mode 100644
index 000000000000..44dec67607b4
--- /dev/null
+++ b/filter/qa/cppunit/data/ras/fail/hang-1.ras
Binary files differ
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index 5877fa2b678a..e3209bd74109 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -222,31 +222,43 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
case 1 :
for (y = 0; y < mnHeight && mbStatus; ++y)
{
- for ( x = 0; x < mnWidth; x++ )
+ for (x = 0; x < mnWidth && mbStatus; ++x)
{
if (!(x & 7))
+ {
nDat = ImplGetByte();
+ if (!m_rRAS.good())
+ mbStatus = false;
+ }
pAcc->SetPixelIndex( y, x,
sal::static_int_cast< sal_uInt8 >(
nDat >> ( ( x & 7 ) ^ 7 )) );
}
- if (!( ( x - 1 ) & 0x8 ) ) ImplGetByte(); // WORD ALIGNMENT ???
- if (!m_rRAS.good())
- mbStatus = false;
+ if (!( ( x - 1 ) & 0x8 ) )
+ {
+ ImplGetByte(); // WORD ALIGNMENT ???
+ if (!m_rRAS.good())
+ mbStatus = false;
+ }
}
break;
case 8 :
for (y = 0; y < mnHeight && mbStatus; ++y)
{
- for ( x = 0; x < mnWidth; x++ )
+ for (x = 0; x < mnWidth && mbStatus; ++x)
{
nDat = ImplGetByte();
pAcc->SetPixelIndex( y, x, nDat );
+ if (!m_rRAS.good())
+ mbStatus = false;
+ }
+ if ( x & 1 )
+ {
+ ImplGetByte(); // WORD ALIGNMENT ???
+ if (!m_rRAS.good())
+ mbStatus = false;
}
- if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ???
- if (!m_rRAS.good())
- mbStatus = false;
}
break;
@@ -257,7 +269,7 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
case 24 :
for (y = 0; y < mnHeight && mbStatus; ++y)
{
- for ( x = 0; x < mnWidth; x++ )
+ for (x = 0; x < mnWidth && mbStatus; ++x)
{
if ( mnType == RAS_TYPE_RGB_FORMAT )
{
@@ -272,17 +284,22 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
nRed = ImplGetByte();
}
pAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) );
+ if (!m_rRAS.good())
+ mbStatus = false;
+ }
+ if ( x & 1 )
+ {
+ ImplGetByte(); // WORD ALIGNMENT ???
+ if (!m_rRAS.good())
+ mbStatus = false;
}
- if ( x & 1 ) ImplGetByte(); // WORD ALIGNMENT ???
- if (!m_rRAS.good())
- mbStatus = false;
}
break;
case 32 :
for (y = 0; y < mnHeight && mbStatus; ++y)
{
- for ( x = 0; x < mnWidth; x++ )
+ for (x = 0; x < mnWidth && mbStatus; ++x)
{
nDat = ImplGetByte(); // pad byte > nil
if ( mnType == RAS_TYPE_RGB_FORMAT )
@@ -298,9 +315,9 @@ bool RASReader::ImplReadBody(BitmapWriteAccess * pAcc)
nRed = ImplGetByte();
}
pAcc->SetPixel ( y, x, BitmapColor( nRed, nGreen, nBlue ) );
+ if (!m_rRAS.good())
+ mbStatus = false;
}
- if (!m_rRAS.good())
- mbStatus = false;
}
break;
}