Again, the != NULL should be replaced with a !is_null().