Fixed memleak. Also, clean up better in exceptional cases.
Fixed memleak. Also, clean up better in exceptional cases.

saulogt/HexFiend,saulogt/HexFiend,thx0701/HexFiend,kedh/HexFiend,saulogt/HexFiend,thx0701/HexFiend,pandazheng/HexFiend,kedh/HexFiend,thx0701/HexFiend,pandazheng/HexFiend,kedh/HexFiend,pandazheng/HexFiend,kedh/HexFiend,thx0701/HexFiend,saulogt/HexFiend,pandazheng/HexFiend