Added checks when freeing proxy and closing socket. Also free open_cb in cancel_open.
Added checks when freeing proxy and closing socket. Also free open_cb in cancel_open.

Patch from Senko Rasic and modified slightly by Mikael Hallendal

mcabber/loudmouth,tyll/loudmouth,mhallendal/loudmouth,tuxad-loudmouth/loudmouth,tuxad-loudmouth/loudmouth,mhallendal/loudmouth,mcabber/loudmouth,tyll/loudmouth