summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Marques <george@gmarqu.es>2019-01-16 20:24:17 -0200
committerGeorge Marques <george@gmarqu.es>2019-01-17 14:38:28 -0200
commit30f02dd421d3104e0929572ab2e572625e2f4e29 (patch)
tree60f82a8b19736869a7d9df4c5a26fb110ba969e5
parentced9fcafd439539c93dddb40b43be7016659ef53 (diff)
GDScript compiler: check if subclass exists before comparison
Otherwise these checks might trigger the insertion of an empty value, leading to crashes.
-rw-r--r--modules/gdscript/gdscript_compiler.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 2b6b66d7b6..e59b57b39a 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -486,7 +486,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
script = codegen.script;
} else {
StringName name = cn->cast_type.class_type->name;
- if (class_map[name] == codegen.script->subclasses[name]) {
+ if (codegen.script->subclasses.has(name) && class_map[name] == codegen.script->subclasses[name]) {
idx = codegen.get_name_map_pos(name);
idx |= GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT << GDScriptFunction::ADDR_BITS;
} else {
@@ -1183,7 +1183,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
script = codegen.script;
} else {
StringName name = assign_type.class_type->name;
- if (class_map[name] == codegen.script->subclasses[name]) {
+ if (codegen.script->subclasses.has(name) && class_map[name] == codegen.script->subclasses[name]) {
idx = codegen.get_name_map_pos(name);
idx |= GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT << GDScriptFunction::ADDR_BITS;
} else {