Fixed bogus test on memory allocation.

(cherry picked from commit d9fe58e721a0e4c53841e91ba766df7bbce2cae5)