add missing checks after memory allocation
add missing memset after memory allocation
Merge remote-tracking branch 'upstream/master'
revert last commit
Merge pull request #44 from lategoodbye/master

fix some handling after memory allocation