Don't use luaL_error in luaA_object_emit_signal (FS#713)
This function can be called from unprotected contexts. Calling luaL_error() in this case results in a call to luaA_panic() and awesome dies. The only real change here is that this now calls warn() instead of luaL_error(). The rest is reindentation because warn() returns while luaL_error() didn't. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
22a5137299
commit
79b1f5aba1
|
@ -255,33 +255,35 @@ luaA_object_emit_signal(lua_State *L, int oud,
|
||||||
int oud_abs = luaA_absindex(L, oud);
|
int oud_abs = luaA_absindex(L, oud);
|
||||||
lua_object_t *obj = lua_touserdata(L, oud);
|
lua_object_t *obj = lua_touserdata(L, oud);
|
||||||
if(!obj)
|
if(!obj)
|
||||||
luaL_error(L, "trying to emit signal on non-object");
|
warn("Trying to emit signal '%s' on non-object", name);
|
||||||
signal_t *sigfound = signal_array_getbyid(&obj->signals,
|
else {
|
||||||
a_strhash((const unsigned char *) name));
|
signal_t *sigfound = signal_array_getbyid(&obj->signals,
|
||||||
if(sigfound)
|
a_strhash((const unsigned char *) name));
|
||||||
{
|
if(sigfound)
|
||||||
int nbfunc = sigfound->sigfuncs.len;
|
|
||||||
luaL_checkstack(L, lua_gettop(L) + nbfunc + nargs + 2, "too much signal");
|
|
||||||
/* Push all functions and then execute, because this list can change
|
|
||||||
* while executing funcs. */
|
|
||||||
foreach(func, sigfound->sigfuncs)
|
|
||||||
luaA_object_push_item(L, oud_abs, (void *) *func);
|
|
||||||
|
|
||||||
for(int i = 0; i < nbfunc; i++)
|
|
||||||
{
|
{
|
||||||
/* push object */
|
int nbfunc = sigfound->sigfuncs.len;
|
||||||
lua_pushvalue(L, oud_abs);
|
luaL_checkstack(L, lua_gettop(L) + nbfunc + nargs + 2, "too much signal");
|
||||||
/* push all args */
|
/* Push all functions and then execute, because this list can change
|
||||||
for(int j = 0; j < nargs; j++)
|
* while executing funcs. */
|
||||||
|
foreach(func, sigfound->sigfuncs)
|
||||||
|
luaA_object_push_item(L, oud_abs, (void *) *func);
|
||||||
|
|
||||||
|
for(int i = 0; i < nbfunc; i++)
|
||||||
|
{
|
||||||
|
/* push object */
|
||||||
|
lua_pushvalue(L, oud_abs);
|
||||||
|
/* push all args */
|
||||||
|
for(int j = 0; j < nargs; j++)
|
||||||
|
lua_pushvalue(L, - nargs - nbfunc - 1 + i);
|
||||||
|
/* push first function */
|
||||||
lua_pushvalue(L, - nargs - nbfunc - 1 + i);
|
lua_pushvalue(L, - nargs - nbfunc - 1 + i);
|
||||||
/* push first function */
|
/* remove this first function */
|
||||||
lua_pushvalue(L, - nargs - nbfunc - 1 + i);
|
lua_remove(L, - nargs - nbfunc - 2 + i);
|
||||||
/* remove this first function */
|
luaA_dofunction(L, nargs + 1, 0);
|
||||||
lua_remove(L, - nargs - nbfunc - 2 + i);
|
}
|
||||||
luaA_dofunction(L, nargs + 1, 0);
|
} else
|
||||||
}
|
warn("Trying to emit unknown signal '%s'", name);
|
||||||
} else
|
}
|
||||||
warn("Trying to emit unknown signal '%s'", name);
|
|
||||||
|
|
||||||
/* Then emit signal on the class */
|
/* Then emit signal on the class */
|
||||||
lua_pushvalue(L, oud);
|
lua_pushvalue(L, oud);
|
||||||
|
|
Loading…
Reference in New Issue