summaryrefslogtreecommitdiffstats
path: root/include/core
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2018-11-24 17:36:27 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2018-11-26 08:11:31 +0200
commitbe5a012ff7f3a4c83613ad0ef9bb8d675be70d2c (patch)
treeca5d5910543b4e359c89a6b137cf66ffe8e1f95d /include/core
parent5225ab2bac147e343fda6de8f025213538f3b7ac (diff)
downloadredot-cpp-be5a012ff7f3a4c83613ad0ef9bb8d675be70d2c.tar.gz
Fix NULL dereferencing in get_from_variant and cast_to
Diffstat (limited to 'include/core')
-rw-r--r--include/core/Godot.hpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/core/Godot.hpp b/include/core/Godot.hpp
index a09310e..414a48a 100644
--- a/include/core/Godot.hpp
+++ b/include/core/Godot.hpp
@@ -24,7 +24,7 @@ namespace godot {
template <class T>
T *as(const Object *obj) {
- return (T *)godot::nativescript_api->godot_nativescript_get_userdata(obj->_owner);
+ return (obj) ? (T *)godot::nativescript_api->godot_nativescript_get_userdata(obj->_owner) : nullptr;
}
template <class T>
@@ -428,6 +428,9 @@ void register_signal(String name, Args... varargs) {
#ifndef GODOT_CPP_NO_OBJECT_CAST
template <class T>
T *Object::cast_to(const Object *obj) {
+ if (!obj)
+ return nullptr;
+
size_t have_tag = (size_t)godot::nativescript_1_1_api->godot_nativescript_get_type_tag(obj->_owner);
if (have_tag) {