From fdd09011f499c9ebe1f73dde1496db54d705f2ec Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Wed, 24 Jan 2024 22:32:15 -0600 Subject: [PATCH] If the input stream fails during level 2 parsing, avoid an infinite loop --- wxdata/source/scwx/wsr88d/ar2v_file.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wxdata/source/scwx/wsr88d/ar2v_file.cpp b/wxdata/source/scwx/wsr88d/ar2v_file.cpp index 2179b835..714e15a1 100644 --- a/wxdata/source/scwx/wsr88d/ar2v_file.cpp +++ b/wxdata/source/scwx/wsr88d/ar2v_file.cpp @@ -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; }