AP_Scripting: try a gc on alloc fail in logging

This commit is contained in:
Andrew Tridgell 2022-12-01 19:29:43 +11:00
parent aa8ff87ad2
commit ff6d9a12a4
1 changed files with 5 additions and 1 deletions

View File

@ -171,7 +171,11 @@ int AP_Logger_Write(lua_State *L) {
lua_Alloc allocf = lua_getallocf(L, nullptr); lua_Alloc allocf = lua_getallocf(L, nullptr);
char *buffer = (char*)allocf(nullptr, nullptr, 0, msg_len); char *buffer = (char*)allocf(nullptr, nullptr, 0, msg_len);
if (buffer == nullptr) { if (buffer == nullptr) {
return luaL_error(L, "Buffer allocation failed"); lua_gc(L, LUA_GCCOLLECT, 0);
buffer = (char*)allocf(nullptr, nullptr, 0, msg_len);
if (buffer == nullptr) {
return luaL_error(L, "Buffer allocation failed");
}
} }
// add logging headers // add logging headers