Problem: allocated string buffers are not NULL checked

Solution: check if malloc doesn’t return NULL
Merge pull request #830 from Asmod4n/master

Problem: allocated string buffers are not NULL checked