Skip to content

Commit

Permalink
Fix crash when casting from null
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyqiu committed Sep 26, 2021
1 parent 7893dd2 commit 8a47fe9
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions core/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,22 +804,15 @@ bool Variant::is_one() const {
}

ObjectID Variant::get_object_instance_id() const {
if (type != OBJECT) {
if (unlikely(type != OBJECT)) {
return 0;
}
#ifdef DEBUG_ENABLED
if (is_ref()) {
return !_get_obj().ref.is_null() ? _REF_OBJ_PTR(*this)->get_instance_id() : 0;
} else {
} else if (likely(_get_obj().rc)) {
return _get_obj().rc->instance_id;
}
#else
if (is_ref() && _get_obj().ref.is_null()) {
return 0;
} else if (likely(!_get_obj().ref.is_null())) {
return _REF_OBJ_PTR(*this)->get_instance_id();
} else {
return _get_obj().rc->get_ptr()->get_instance_id();
return 0;
}
#endif
}

bool Variant::is_invalid_object() const {
Expand Down

0 comments on commit 8a47fe9

Please sign in to comment.