Added safety check for malloc return
Merge pull request #489 from lixar/feature/malloc-check

Added safety check for malloc return