diff --git a/libraries/AP_Scripting/lua_bindings.cpp b/libraries/AP_Scripting/lua_bindings.cpp index ffa3e349fe00b..f4cf9bb30735b 100644 --- a/libraries/AP_Scripting/lua_bindings.cpp +++ b/libraries/AP_Scripting/lua_bindings.cpp @@ -826,6 +826,7 @@ int SocketAPM_close(lua_State *L) { ud->close(); delete ud; scripting->_net_sockets[i] = nullptr; + *check_SocketAPM(L, 1) = nullptr; break; } }