From d50e9865bde46af4f05a325aacd9f70a8efd2cc5 Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Fri, 27 Mar 2020 20:11:09 -0700 Subject: [PATCH] AP_Scripting: Delete the lua object if we failed to allocate the required memory --- libraries/AP_Scripting/AP_Scripting.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/AP_Scripting/AP_Scripting.cpp b/libraries/AP_Scripting/AP_Scripting.cpp index 002232cf0d..add227b54a 100644 --- a/libraries/AP_Scripting/AP_Scripting.cpp +++ b/libraries/AP_Scripting/AP_Scripting.cpp @@ -157,6 +157,7 @@ void AP_Scripting::thread(void) { lua_scripts *lua = new lua_scripts(_script_vm_exec_count, _script_heap_size, _debug_level, terminal); if (lua == nullptr || !lua->heap_allocated()) { gcs().send_text(MAV_SEVERITY_CRITICAL, "Unable to allocate scripting memory"); + delete lua; _init_failed = true; return; }