Fixed errors reported by coverity (mostly missing null checks after some allocs)
fixed coverity null deref
Merge pull request #88 from buixor/master

Coverity fixes o/