Fixed a clang-reported NULL pointer dereference issue.
Corrected a clang-reported issue where NULL might be passed to emalloc().