From 545604da63327f3767c0f9fb49be5da8e202ab59 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 5 Oct 2021 18:46:57 +0200 Subject: [PATCH] sys: Fixed reading empty file as string crashing --- plugins/libimhex/source/helpers/file.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/libimhex/source/helpers/file.cpp b/plugins/libimhex/source/helpers/file.cpp index 11cb92de9..cbfce32da 100644 --- a/plugins/libimhex/source/helpers/file.cpp +++ b/plugins/libimhex/source/helpers/file.cpp @@ -57,6 +57,8 @@ namespace hex { std::string File::readString(size_t numBytes) { if (!isValid()) return { }; + if (getSize() == 0) return { }; + return reinterpret_cast(readBytes(numBytes).data()); }