Coverity: fix finding in COBLoader.

pull/1259/head
Kim Kulling 2017-05-09 20:15:30 +02:00
parent a2b8d66a86
commit 03d97b23ec
1 changed files with 9 additions and 7 deletions

View File

@ -941,20 +941,22 @@ void COBImporter::UnsupportedChunk_Binary( StreamReaderLE& reader, const ChunkIn
// ------------------------------------------------------------------------------------------------
// tiny utility guard to aid me at staying within chunk boundaries.
class chunk_guard {
public:
chunk_guard(const COB::ChunkInfo& nfo, StreamReaderLE& reader)
: nfo(nfo)
, reader(reader)
, cur(reader.GetCurrentPos())
{
: nfo(nfo)
, reader(reader)
, cur(reader.GetCurrentPos()) {
}
~chunk_guard() {
// don't do anything if the size is not given
if(nfo.size != static_cast<unsigned int>(-1)) {
reader.IncPtr(static_cast<int>(nfo.size)-reader.GetCurrentPos()+cur);
try {
reader.IncPtr( static_cast< int >( nfo.size ) - reader.GetCurrentPos() + cur );
} catch ( DeadlyImportError e ) {
// out of limit so correct the value
reader.IncPtr( reader.GetReadLimit() );
}
}
}