Error handling fixes.
Found one double free() bug causing troubles when a buddy_msg() handler takes down the IM connection immediately.