[ox/mc] Replace an alloca call with malloca to prevent stack overflow

This commit is contained in:
Gary Talent 2020-06-20 03:54:16 -05:00
parent a9ec635160
commit dbf532df1c

View File

@ -185,9 +185,9 @@ template<typename T>
for (std::size_t i = 0; i < len; i++) { for (std::size_t i = 0; i < len; i++) {
auto &key = keys[i]; auto &key = keys[i];
const auto keyLen = ox_strlen(key); const auto keyLen = ox_strlen(key);
auto wkey = static_cast<char*>(ox_alloca(keyLen + 1)); auto wkey = ox_malloca(keyLen + 1, char, 0);
memcpy(wkey, key.c_str(), keyLen + 1); memcpy(wkey, key.c_str(), keyLen + 1);
oxReturnError(writer.field("", SerStr(&wkey, keyLen))); oxReturnError(writer.field("", SerStr(wkey.get(), keyLen)));
oxReturnError(writer.field("", &(*val)[key])); oxReturnError(writer.field("", &(*val)[key]));
} }