From b17ab3f8e9eabf545201b8a8e21ff4c7050149b1 Mon Sep 17 00:00:00 2001 From: Anakin Date: Thu, 2 Feb 2017 15:26:40 +0100 Subject: [PATCH] fixed out of file check order --- QtMeshViewer/Source/MshFile.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/QtMeshViewer/Source/MshFile.cpp b/QtMeshViewer/Source/MshFile.cpp index be4ef10..16aef39 100644 --- a/QtMeshViewer/Source/MshFile.cpp +++ b/QtMeshViewer/Source/MshFile.cpp @@ -74,6 +74,15 @@ void MshFile::loadChunks(QList& destination, qint64 start, const q do { + // out of file. Maybe a size information is corrupted + if (m_file.atEnd() || m_file.error() != QFileDevice::NoError) + { + OutputDevice::getInstance()->print("WARNING: corrupted file. Trying to continue..", 1); + m_file.unsetError(); + m_file.seek(0); + break; + } + ChunkHeader* tmp_header = new ChunkHeader(); char workaround[5] = { 0 }; @@ -89,14 +98,6 @@ void MshFile::loadChunks(QList& destination, qint64 start, const q // jump to next header m_file.seek(tmp_header->size + m_file.pos()); - // out of file. Maybe a size information is corrupted - if (m_file.atEnd() || m_file.error() != QFileDevice::NoError) - { - OutputDevice::getInstance()->print("WARNING: corrupted file. Trying to continue..", 1); - m_file.unsetError(); - m_file.seek(0); - break; - } } while (m_file.pos() - start != length); }