Fix possible crash at NativeScript::get_base_script

This commit is contained in:
Marcelo Fernandez 2018-07-22 17:41:50 -03:00
parent 4b549faaab
commit 77f3c0b495
1 changed files with 4 additions and 1 deletions

View File

@ -149,7 +149,10 @@ Ref<Script> NativeScript::get_base_script() const {
if (!script_data) if (!script_data)
return Ref<Script>(); return Ref<Script>();
Ref<NativeScript> ns = Ref<NativeScript>(NSL->create_script()); NativeScript *script = (NativeScript *)NSL->create_script();
Ref<NativeScript> ns = Ref<NativeScript>(script);
ERR_FAIL_COND_V(!ns.is_valid(), Ref<Script>());
ns->set_class_name(script_data->base); ns->set_class_name(script_data->base);
ns->set_library(get_library()); ns->set_library(get_library());
return ns; return ns;