diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-17 12:57:44 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-17 14:53:24 +0000 |
commit | a7d26c9f252f35eb18d8ab2900e4a6f67ca2e875 (patch) | |
tree | ccc56fb85caa014fd37acbfd0a83fecd6a805899 /vcl | |
parent | 6b709b27b3552ced17b612b78f1c8cadc81f620c (diff) |
coverity#1242859 rework to silence Untrusted loop bound
Change-Id: Ic30dd457b0f2fdbd13aa1508f97cdda6364390e4
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/regionband.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/vcl/source/gdi/regionband.cxx b/vcl/source/gdi/regionband.cxx index 4e37854e5f08..05f3f7f83595 100644 --- a/vcl/source/gdi/regionband.cxx +++ b/vcl/source/gdi/regionband.cxx @@ -199,10 +199,21 @@ void RegionBand::load(SvStream& rIStrm) ImplRegionBand* pCurrBand = 0; // get header from first element - sal_uInt16 nTmp16(0); - rIStrm.ReadUInt16( nTmp16 ); + sal_uInt16 nTmp16(STREAMENTRY_END); + rIStrm.ReadUInt16(nTmp16); - while(STREAMENTRY_END != (StreamEntryType)nTmp16) + if (STREAMENTRY_END == (StreamEntryType)nTmp16) + return; + + size_t nRecordsPossible = rIStrm.remainingSize() / (2*sizeof(sal_Int32)); + if (!nRecordsPossible) + { + OSL_ENSURE(false, "premature end of region stream" ); + implReset(); + return; + } + + do { // insert new band or new separation? if(STREAMENTRY_BANDHEADER == (StreamEntryType)nTmp16) @@ -254,6 +265,7 @@ void RegionBand::load(SvStream& rIStrm) // get next header rIStrm.ReadUInt16( nTmp16 ); } + while(STREAMENTRY_END != (StreamEntryType)nTmp16); } |