Fix missing NULL check