Merge pull request #15724 from karroffel/gdnative-fix-some-crashes

[GDNative] fix two crashes with NativeScript
This commit is contained in:
Rémi Verschelde 2018-01-15 20:18:50 +01:00 committed by GitHub
commit 700a1a9096
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -398,6 +398,11 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call
owner = memnew(Reference);
}
if (!owner) {
r_error.error = Variant::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
Reference *r = Object::cast_to<Reference>(owner);
if (r) {
ref = REF(r);
@ -793,7 +798,7 @@ NativeScriptLanguage *NativeScriptLanguage::singleton;
void NativeScriptLanguage::_unload_stuff(bool p_reload) {
for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) {
if (p_reload && !library_gdnatives[L->key()]->get_library()->is_reloadable()) {
if (p_reload && library_gdnatives[L->key()].is_valid() && !library_gdnatives[L->key()]->get_library()->is_reloadable()) {
continue;
}