From 55ba2602db0cb6be647ec9a8b9d8246aa9e1d575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gilles=20Roudi=C3=A8re?= Date: Mon, 22 Nov 2021 16:57:51 +0100 Subject: [PATCH] Avoid crash in Variant constructor from nullptr Object* --- src/variant/variant.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/variant/variant.cpp b/src/variant/variant.cpp index 4535f736..82b0b149 100644 --- a/src/variant/variant.cpp +++ b/src/variant/variant.cpp @@ -171,7 +171,12 @@ Variant::Variant(const godot::RID &v) { } Variant::Variant(const Object *v) { - from_type_constructor[OBJECT](ptr(), const_cast(&v->_owner)); + if (v) { + from_type_constructor[OBJECT](ptr(), const_cast(&v->_owner)); + } else { + GodotObject *nullobject = nullptr; + from_type_constructor[OBJECT](ptr(), &nullobject); + } } Variant::Variant(const Callable &v) {