From 537ecd10430e5d2cd8ccf28b5956cc2507d61a5a 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 (synced from dbf532df1c4003bac7c6056bd25ba2618a307361) --- src/ox/mc/write.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ox/mc/write.hpp b/src/ox/mc/write.hpp index 8d6de382a..a5ab40f13 100644 --- a/src/ox/mc/write.hpp +++ b/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])); }