Checking for valid object before calling get_object_vars.