check for malloc failures