Added check for unlikely case where malloc fails and returns NULL

Added check for the rare case where a malloc could fail and return NULL as a
result. This is primarily to make a static scan tool happy.

Related to [this issue](https://github.com/m1entus/MZAppearance/issues/2)