Fix a crash on rare memory allocation failures.