Fix memory leak
Fix double free
Bad size_of
Fixed potential null dereference
Merge pull request #137 from Hamcha/master

Clang analyzer fixes