window: fix invalid env buffer size in getEnv

This commit is contained in:
Vaxry 2024-05-24 20:40:15 +02:00
parent 4e42107d25
commit 52684b7d90

View file

@ -1296,9 +1296,12 @@ std::unordered_map<std::string, std::string> CWindow::getEnv() {
needle += 512; needle += 512;
} }
if (needle <= 1)
return {};
std::replace(buffer.begin(), buffer.end() - 1, '\0', '\n'); 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) { for (auto& e : envs) {
if (!e.contains('=')) if (!e.contains('='))