From dbf532df1c4003bac7c6056bd25ba2618a307361 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 20 Jun 2020 03:54:16 -0500 Subject: [PATCH] [ox/mc] Replace an alloca call with malloca to prevent stack overflow --- deps/ox/src/ox/mc/write.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index 8d6de382..a5ab40f1 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -185,9 +185,9 @@ template for (std::size_t i = 0; i < len; i++) { auto &key = keys[i]; const auto keyLen = ox_strlen(key); - auto wkey = static_cast(ox_alloca(keyLen + 1)); + auto wkey = ox_malloca(keyLen + 1, char, 0); 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])); }