From 39da62532b5c70bd8ebdf82100aad26ff3764108 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 3 Mar 2022 09:27:27 +0100 Subject: [PATCH] fix: Trailing zero at end of string input buffers --- lib/libimhex/source/ui/imgui_imhex_extensions.cpp | 6 ------ plugins/builtin/source/content/tools_entries.cpp | 8 +------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index e0b25599c..039bd7179 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -559,16 +559,10 @@ namespace ImGui { } bool InputText(const char *label, std::string &buffer, ImGuiInputTextFlags flags) { - if (buffer.empty()) - buffer.resize(1, 0x00); - return ImGui::InputText(label, buffer.data(), buffer.size(), ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); } bool InputTextMultiline(const char *label, std::string &buffer, const ImVec2 &size, ImGuiInputTextFlags flags) { - if (buffer.empty()) - buffer.resize(1, 0x00); - return ImGui::InputTextMultiline(label, buffer.data(), buffer.size(), size, ImGuiInputTextFlags_CallbackResize | flags, ImGui::UpdateStringSizeCallback, &buffer); } diff --git a/plugins/builtin/source/content/tools_entries.cpp b/plugins/builtin/source/content/tools_entries.cpp index 681c106b8..7904add87 100644 --- a/plugins/builtin/source/content/tools_entries.cpp +++ b/plugins/builtin/source/content/tools_entries.cpp @@ -131,13 +131,7 @@ namespace hex::plugin::builtin { void drawMathEvaluator() { static std::vector mathHistory; static std::string lastMathError; - static auto mathInput = [] { - std::string s; - s.reserve(0xFFFF); - std::memset(s.data(), 0x00, s.capacity()); - - return s; - }(); + static std::string mathInput; bool evaluate = false; static MathEvaluator mathEvaluator = [&] {