[ox/mc] Replace an alloca call with malloca to prevent stack overflow
This commit is contained in:
parent
a9ec635160
commit
dbf532df1c
4
deps/ox/src/ox/mc/write.hpp
vendored
4
deps/ox/src/ox/mc/write.hpp
vendored
@ -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]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user