If the input stream fails during level 2 parsing, avoid an infinite loop

This commit is contained in:
Dan Paulat 2024-01-24 22:32:15 -06:00
parent 3705ca4f2e
commit fdd09011f4

View file

@ -355,13 +355,13 @@ void Ar2vFileImpl::ParseLDMRecord(std::istream& is)
{
is.seekg(-2, std::ios_base::cur);
}
} while (!is.eof() && nextSize == 0u);
} while (!is.eof() && !is.fail() && nextSize == 0u);
if (!is.eof() && offset != 0)
if (!is.eof() && !is.fail() && offset != 0)
{
logger_->trace("Next record offset by {} bytes", offset);
}
else if (is.eof())
else if (is.eof() || is.fail())
{
break;
}