From 088205385f83cdb8be9970147f9dc786a0c8193a Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 28 May 2022 16:18:55 +0200 Subject: [PATCH] fix: Workaround that broke functionality. Instead disable warnings This actually fixes #515 for now --- lib/libimhex/include/hex/helpers/encoding_file.hpp | 5 +++++ lib/libimhex/source/helpers/encoding_file.cpp | 4 ---- lib/libimhex/source/helpers/utils.cpp | 6 +++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/libimhex/include/hex/helpers/encoding_file.hpp b/lib/libimhex/include/hex/helpers/encoding_file.hpp index 05ffa451a..92fb50a82 100644 --- a/lib/libimhex/include/hex/helpers/encoding_file.hpp +++ b/lib/libimhex/include/hex/helpers/encoding_file.hpp @@ -2,9 +2,14 @@ #include +// TODO: Workaround for weird issue picked up by GCC 12.1.0 and later. This seems like a compiler bug mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98465 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wrestrict" +#pragma GCC diagnostic ignored "-Wstringop-overread" #include #include #include +#pragma GCC diagnostic pop #include #include diff --git a/lib/libimhex/source/helpers/encoding_file.cpp b/lib/libimhex/source/helpers/encoding_file.cpp index 0fbd63ea5..410908e7c 100644 --- a/lib/libimhex/source/helpers/encoding_file.cpp +++ b/lib/libimhex/source/helpers/encoding_file.cpp @@ -42,10 +42,6 @@ namespace hex { continue; if (delimiterPos >= line.length()) continue; - if (delimiterPos >= from.length()) - continue; - if (delimiterPos >= to.length()) - continue; from = line.substr(0, delimiterPos); to = line.substr(delimiterPos + 1); diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 5fb07aeb2..48d5f0e04 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -204,11 +204,15 @@ namespace hex { } std::vector splitString(const std::string &string, const std::string &delimiter) { - size_t start = 0, end; + size_t start = 0, end = 0; std::string token; std::vector res; while ((end = string.find(delimiter, start)) != std::string::npos) { + size_t size = end - start; + if (start + size > string.length()) + break; + token = string.substr(start, end - start); start = end + delimiter.length(); res.push_back(token);