summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-09-10 17:24:57 +0200
committerRémi Verschelde <rverschelde@gmail.com>2018-09-10 20:46:20 +0200
commit0faafa6f4d80cf0b89cd60d925d9165fb148bc91 (patch)
tree31d5adc55be0eb50c411db11a115fa3b46786c66 /modules/gdscript/gdscript.cpp
parent6d7a8a6caa225bca2e07bf1d3d196e841ce47e28 (diff)
downloadredot-engine-0faafa6f4d80cf0b89cd60d925d9165fb148bc91.tar.gz
Fix crash when extending non-existing GDScript file
Fixes #21682 with a partial revert of #21411. The ~Ref() destructor (from 'scriptres') already takes care of freeing the 'script' resource.
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r--modules/gdscript/gdscript.cpp13
1 files changed, 2 insertions, 11 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 33d9c011f2..cf4fe29c86 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -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();
}