mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-07 00:18:29 -04:00
AP_Scripting: fixed use after free bug
found with valgrind
This commit is contained in:
parent
1d0fc4e87c
commit
6fb99d6b1e
@ -402,19 +402,18 @@ void lua_scripts::remove_script(lua_State *L, script_info *script) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (L != nullptr) {
|
|
||||||
// state could be null if we are force killing all scripts
|
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, script->lua_ref);
|
|
||||||
}
|
|
||||||
_heap.deallocate(script->name);
|
|
||||||
_heap.deallocate(script);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Remove from running checksum
|
// Remove from running checksum
|
||||||
WITH_SEMAPHORE(crc_sem);
|
WITH_SEMAPHORE(crc_sem);
|
||||||
running_checksum ^= script->crc;
|
running_checksum ^= script->crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (L != nullptr) {
|
||||||
|
// state could be null if we are force killing all scripts
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, script->lua_ref);
|
||||||
|
}
|
||||||
|
_heap.deallocate(script->name);
|
||||||
|
_heap.deallocate(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lua_scripts::reschedule_script(script_info *script) {
|
void lua_scripts::reschedule_script(script_info *script) {
|
||||||
|
Loading…
Reference in New Issue
Block a user