Fix a couple of memory issue spotted by Valgrind

This PR fixes a couple of memory issues detected by Valgrind. After fixing the memleak originated in KLEE, I saw that there was a similar commit waiting in KLEE PR queue, so I actually cherry-picked and backported it from ccadar/klee#11 instead of mine (hoping that it will get merged soon).