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