BUG: fix missing check for memory allocation failure in ufuncs

closes gh-4018