summaryrefslogtreecommitdiffstats
path: root/modules/gdscript/gdscript_cache.cpp
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2020-08-17 21:30:39 -0300
committerGeorge Marques <george@gmarqu.es>2020-08-17 21:30:39 -0300
commit3abb3c0d6e9e81d3ed171162cc5ce2bbe58296e0 (patch)
tree38b0b7221a0f656447ab4bd0b31aeb5a83a9eadf /modules/gdscript/gdscript_cache.cpp
parentfda6f3b600e124d9fefa3886d2feba1ce32db99f (diff)
downloadredot-engine-3abb3c0d6e9e81d3ed171162cc5ce2bbe58296e0.tar.gz
GDScript: Fix crash when superclass file is non-existent
Incidentally, allow EOF to be an end of statement.
Diffstat (limited to 'modules/gdscript/gdscript_cache.cpp')
-rw-r--r--modules/gdscript/gdscript_cache.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp
index 583283ff46..cdb14d6281 100644
--- a/modules/gdscript/gdscript_cache.cpp
+++ b/modules/gdscript/gdscript_cache.cpp
@@ -85,6 +85,17 @@ Error GDScriptParserRef::raise_status(Status p_new_status) {
return result;
}
}
+ if (result != OK) {
+ if (parser != nullptr) {
+ memdelete(parser);
+ parser = nullptr;
+ }
+ if (analyzer != nullptr) {
+ memdelete(analyzer);
+ analyzer = nullptr;
+ }
+ return result;
+ }
}
return result;
@@ -118,6 +129,10 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
if (singleton->parser_map.has(p_path)) {
ref = singleton->parser_map[p_path];
} else {
+ if (!FileAccess::exists(p_path)) {
+ r_error = ERR_FILE_NOT_FOUND;
+ return ref;
+ }
GDScriptParser *parser = memnew(GDScriptParser);
ref.instance();
ref->parser = parser;