mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-11-09 16:41:21 +08:00
AP_Scripting: add init failure check
This commit is contained in:
1 parent
2c3beb0f91
commit
09d75cff3b
3 files changed
+9
-2
No files matched your search
@@ -87,7 +87,7 @@ bool AP_Scripting::init(void) {
|
||||
if (!hal.scheduler->thread_create(FUNCTOR_BIND_MEMBER(&AP_Scripting::thread, void),
|
||||
"Scripting", SCRIPTING_STACK_SIZE, AP_HAL::Scheduler::PRIORITY_SCRIPTING, 0)) {
|
||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "Could not create scripting stack (%d)", SCRIPTING_STACK_SIZE);
|
||||
_enable = 0;
|
||||
_init_failed = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,9 @@ bool AP_Scripting::init(void) {
|
||||
|
||||
void AP_Scripting::thread(void) {
|
||||
lua_scripts *lua = new lua_scripts(_script_vm_exec_count, _script_heap_size, _debug_level);
|
||||
if (lua == nullptr) {
|
||||
if (lua == nullptr || !lua->heap_allocated()) {
|
||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "Unable to allocate scripting memory");
|
||||
_init_failed = true;
|
||||
return;
|
||||
}
|
||||
lua->run();
|
||||
|
||||
Reference in new issue
Block a user