luaA_object_emit_signal: check for valid object

By the time a signal gets emitted the object might be invalid already,
e.g. when it is very short-lived and unmanaged by the time the delayed
call to emit_signal is being invoked.

Ref: https://github.com/awesomeWM/awesome/pull/87#issuecomment-70901168
This commit is contained in:
Daniel Hahler 2015-02-10 14:52:47 +01:00
parent 1c6463822e
commit f562b4a64b
1 changed files with 6 additions and 1 deletions

View File

@ -253,11 +253,16 @@ luaA_object_emit_signal(lua_State *L, int oud,
const char *name, int nargs)
{
int oud_abs = luaA_absindex(L, oud);
lua_object_t *obj = lua_touserdata(L, oud);
lua_class_t *lua_class = luaA_class_get(L, oud);
lua_object_t *obj = luaA_toudata(L, oud, lua_class);
if(!obj) {
warn("Trying to emit signal '%s' on non-object", name);
return;
}
else if(lua_class->checker && !lua_class->checker(obj)) {
warn("Trying to emit signal '%s' on invalid object", name);
return;
}
signal_t *sigfound = signal_array_getbyid(&obj->signals,
a_strhash((const unsigned char *) name));
if(sigfound)