From c55fcbbb12fa91da10ca8181b59784dc547e099b Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 8 Mar 2023 01:27:57 +0100 Subject: [PATCH] UI: Use binary mode for QuickReadFile When not using binary mode (i.e. text mode) CRLF will be converted to LF, which means that the size provided by tellg() is no longer correct, and reading prematurely hits an EOF and sets the fail bit. --- UI/update/shared-update.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UI/update/shared-update.cpp b/UI/update/shared-update.cpp index ad8f778a1..a458592e1 100644 --- a/UI/update/shared-update.cpp +++ b/UI/update/shared-update.cpp @@ -68,7 +68,7 @@ try { static bool QuickReadFile(const char *file, std::string &data) try { - std::ifstream fileStream(file); + std::ifstream fileStream(file, std::ifstream::binary); if (!fileStream.is_open() || fileStream.fail()) throw strprintf("Failed to open file '%s': %s", file, strerror(errno));