Merge pull request #21941 from akien-mga/gdscript-memdelete-missing-script

Fix crash when extending non-existing GDScript file
This commit is contained in:
Rémi Verschelde 2018-09-10 23:11:54 +02:00 committed by GitHub
commit c440bf82d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2112,23 +2112,14 @@ RES ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_ori
script->set_script_path(p_original_path); // script needs this.
script->set_path(p_original_path);
Error err = script->load_byte_code(p_path);
if (err != OK) {
memdelete(script);
ERR_FAIL_COND_V(err != OK, RES());
}
ERR_FAIL_COND_V(err != OK, RES());
} else {
Error err = script->load_source_code(p_path);
if (err != OK) {
memdelete(script);
ERR_FAIL_COND_V(err != OK, RES());
}
ERR_FAIL_COND_V(err != OK, RES());
script->set_script_path(p_original_path); // script needs this.
script->set_path(p_original_path);
//script->set_name(p_path.get_file());
script->reload();
}