check for malloc failure