From 52684b7d90de509c66f4f9a81c54a985123315b6 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 24 May 2024 20:40:15 +0200 Subject: [PATCH] window: fix invalid env buffer size in getEnv --- src/desktop/Window.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 7987c9d6..7a06aa61 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1296,9 +1296,12 @@ std::unordered_map CWindow::getEnv() { needle += 512; } + if (needle <= 1) + return {}; + std::replace(buffer.begin(), buffer.end() - 1, '\0', '\n'); - CVarList envs(std::string{buffer.data(), needle - 1}, 0, '\n', true); + CVarList envs(std::string{buffer.data(), buffer.size() - 1}, 0, '\n', true); for (auto& e : envs) { if (!e.contains('='))