event_callback: Fix segmentation fault

If an event is closed and an error occurs in the same callback, it would
cause a segfault due to cb->base being NULL
event_callback: Keep declarations at the top
Merge pull request #3 from Zash/fix-segfault

event_callback: Fix segmentation fault