From be5260d0af0b9fc3f10dce9813e362eda66eba51 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 16 Jan 2012 04:21:17 +0000 Subject: event_callback.c: Check for event being destroyed during callback --- src/event_callback.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/event_callback.c b/src/event_callback.c index b1cdd02..1bf18ec 100644 --- a/src/event_callback.c +++ b/src/event_callback.c @@ -24,16 +24,15 @@ void luaevent_callback(int fd, short event, void* p) { int ret; double newTimeout = -1; assert(cb); - if(!cb->base) { - /* Callback has been collected... die */ - /* TODO: What should really be done here... */ - return; - } + if(!cb->base) + return; /* Event has already been collected + destroyed */ assert(cb->base->loop_L); L = cb->base->loop_L; lua_rawgeti(L, LUA_REGISTRYINDEX, cb->callbackRef); lua_pushinteger(L, event); lua_call(L, 1, 2); + if(!cb->base) + return; /* event was destroyed during callback */ ret = lua_tointeger(L, -2); if(lua_isnumber(L, -1)) { newTimeout = lua_tonumber(L, -1); -- cgit v1.2.3