From b58bc685e1004d75ae2c13b1890355423534fa94 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 25 Jan 2021 13:36:25 +0100 Subject: [PATCH] Extra formatting check in hex::format --- plugins/libimhex/include/hex/helpers/utils.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/libimhex/include/hex/helpers/utils.hpp b/plugins/libimhex/include/hex/helpers/utils.hpp index 7226cc013..12c43a759 100644 --- a/plugins/libimhex/include/hex/helpers/utils.hpp +++ b/plugins/libimhex/include/hex/helpers/utils.hpp @@ -116,7 +116,9 @@ namespace hex { return ""; std::vector buffer(size + 1, 0x00); - snprintf(buffer.data(), size + 1, format, args ...); + if (snprintf(buffer.data(), size, format, args ...) <= 0) + return ""; + return std::string(buffer.data(), buffer.data() + size); }