Added check to ensure malloced buffer is non-null prior to use.
Merge pull request #5 from nmccann/unchecked_malloc_fix

Added check to ensure malloced buffer is non-null prior to use.