mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-04 08:46:09 +00:00
Avoid removing random values from the Lua registry using Events:off()
Fix proposed in: https://github.com/aseprite/aseprite/pull/2980#issuecomment-938495522
This commit is contained in:
parent
2ddbbf00d6
commit
318d5ed6a0
@ -289,7 +289,10 @@ int Events_off(lua_State* L)
|
||||
return luaL_error(L, "first argument must be a function or a EventListener");
|
||||
}
|
||||
|
||||
if (callbackRef != LUA_REFNIL) {
|
||||
if (callbackRef != LUA_REFNIL &&
|
||||
// Check that we are removing a listener from this Events and no
|
||||
// other random value from the Lua registry
|
||||
evs->hasListener(callbackRef)) {
|
||||
evs->remove(callbackRef);
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, callbackRef);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user