From b28eaf2dbfcb719aae2cbb7c4f14873764da60b6 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 26 Feb 2022 17:15:35 +0100 Subject: [PATCH] sys: Catch error produced in file size querying --- lib/libimhex/source/helpers/file.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libimhex/source/helpers/file.cpp b/lib/libimhex/source/helpers/file.cpp index 8dc276979..84939b015 100644 --- a/lib/libimhex/source/helpers/file.cpp +++ b/lib/libimhex/source/helpers/file.cpp @@ -103,9 +103,12 @@ namespace hex { auto startPos = ftello64(this->m_file); fseeko64(this->m_file, 0, SEEK_END); - size_t size = ftello64(this->m_file); + auto size = ftello64(this->m_file); fseeko64(this->m_file, startPos, SEEK_SET); + if (size < 0) + return 0; + return size; }