Fix crash due to incorrect NULL check.