diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-09-11 15:38:01 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2015-09-14 07:21:54 +0000 |
commit | 07e60c9fe65002f698524a838150c457daef2d77 (patch) | |
tree | cee13d6ff564c9fa948774f7f59925fbf16f7bcd /filter | |
parent | c9e824687521ef2c3a90ba969627178b372d885c (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>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/qa/cppunit/data/ras/fail/hang-1.ras | bin | 0 -> 40 bytes | |||
-rw-r--r-- | filter/source/graphicfilter/iras/iras.cxx | 47 |
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 Binary files differnew file mode 100644 index 000000000000..44dec67607b4 --- /dev/null +++ b/filter/qa/cppunit/data/ras/fail/hang-1.ras 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; } |