Skip to content

Commit 50512f0

Browse files
authored
Merge pull request #659 from groud/fix_null_init
Avoid crash in Variant constructor from nullptr Object*
2 parents d619c61 + 55ba260 commit 50512f0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/variant/variant.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ Variant::Variant(const godot::RID &v) {
171171
}
172172

173173
Variant::Variant(const Object *v) {
174-
from_type_constructor[OBJECT](ptr(), const_cast<GodotObject **>(&v->_owner));
174+
if (v) {
175+
from_type_constructor[OBJECT](ptr(), const_cast<GodotObject **>(&v->_owner));
176+
} else {
177+
GodotObject *nullobject = nullptr;
178+
from_type_constructor[OBJECT](ptr(), &nullobject);
179+
}
175180
}
176181

177182
Variant::Variant(const Callable &v) {

0 commit comments

Comments
 (0)