dbus: Make sure the lua stack is balanced
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
8882cf360a
commit
4f6c6cf32e
9
dbus.c
9
dbus.c
|
@ -348,6 +348,7 @@ static void
|
|||
a_dbus_process_request(DBusConnection *dbus_connection, DBusMessage *msg)
|
||||
{
|
||||
const char *interface = dbus_message_get_interface(msg);
|
||||
int old_top = lua_gettop(globalconf.L);
|
||||
|
||||
lua_createtable(globalconf.L, 0, 5);
|
||||
|
||||
|
@ -428,8 +429,8 @@ a_dbus_process_request(DBusConnection *dbus_connection, DBusMessage *msg)
|
|||
{
|
||||
luaA_warn(globalconf.L,
|
||||
"your D-Bus signal handling method returned wrong number of arguments");
|
||||
/* Remove returned values from the stack */
|
||||
lua_pop(globalconf.L, - n);
|
||||
/* Restore stack */
|
||||
lua_settop(globalconf.L, old_top);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -439,6 +440,8 @@ a_dbus_process_request(DBusConnection *dbus_connection, DBusMessage *msg)
|
|||
if(!a_dbus_convert_value(globalconf.L, i, &iter))
|
||||
{
|
||||
luaA_warn(globalconf.L, "your D-Bus signal handling method returned bad data");
|
||||
/* Restore stack */
|
||||
lua_settop(globalconf.L, old_top);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -450,6 +453,8 @@ a_dbus_process_request(DBusConnection *dbus_connection, DBusMessage *msg)
|
|||
dbus_message_unref(reply);
|
||||
}
|
||||
}
|
||||
/* Restore stack */
|
||||
lua_settop(globalconf.L, old_top);
|
||||
}
|
||||
|
||||
/** Attempt to process all the requests in the D-Bus connection.
|
||||
|
|
Loading…
Reference in New Issue