From 2e3c43ad9e21f38048b8bcbd16acfaa20d6768aa Mon Sep 17 00:00:00 2001 From: qdlmcfresh Date: Thu, 11 Nov 2021 13:24:01 +0100 Subject: [PATCH] Fix buffer sizes of PatternDataString16 (#339) --- .../libimhex/include/hex/pattern_language/pattern_data.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp index 26a3cde7e..94182db76 100644 --- a/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp +++ b/plugins/libimhex/include/hex/pattern_language/pattern_data.hpp @@ -679,7 +679,7 @@ namespace hex::pl { void createEntry(prv::Provider* &provider) override { auto size = std::min(this->getSize(), 0x100); - std::u16string buffer(size, 0x00); + std::u16string buffer(this->getSize()/sizeof(char16_t), 0x00); provider->read(this->getOffset(), buffer.data(), size); for (auto &c : buffer) @@ -699,8 +699,8 @@ namespace hex::pl { } [[nodiscard]] std::string toString(prv::Provider *provider) const override { - std::u16string buffer(this->getSize(), 0x00); - provider->read(this->getOffset(), buffer.data(), buffer.size()); + std::u16string buffer(this->getSize()/sizeof(char16_t), 0x00); + provider->read(this->getOffset(), buffer.data(), this->getSize()); for (auto &c : buffer) c = hex::changeEndianess(c, 2, this->getEndian());