Fix possible crash at NativeScript::get_base_script

(cherry picked from commit 77f3c0b495)
This commit is contained in:
Marcelo Fernandez 2018-07-22 17:41:50 -03:00 committed by Rémi Verschelde
parent 754514df7e
commit 5c69f83c96
1 changed files with 4 additions and 1 deletions

View File

@ -150,7 +150,10 @@ Ref<Script> NativeScript::get_base_script() const {
if (!script_data)
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_library(get_library());
return ns;