瀏覽代碼

Fix crash with consecutive commas in Dictionary

kobewi 4 年之前
父節點
當前提交
c7452a9940

+ 4 - 2
modules/gdscript/gdscript_parser.cpp

@@ -2462,8 +2462,10 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_dictionary(ExpressionNode
 							push_error(R"(Expected "=" after dictionary key.)");
 						}
 					}
-					key->is_constant = true;
-					key->reduced_value = static_cast<IdentifierNode *>(key)->name;
+					if (key != nullptr) {
+						key->is_constant = true;
+						key->reduced_value = static_cast<IdentifierNode *>(key)->name;
+					}
 					break;
 				case DictionaryNode::PYTHON_DICT:
 					if (!match(GDScriptTokenizer::Token::COLON)) {

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.gd

@@ -0,0 +1,2 @@
+func test():
+    var dictionary = { hello = "world",, }

+ 2 - 0
modules/gdscript/tests/scripts/parser/errors/double_dictionary_comma.out

@@ -0,0 +1,2 @@
+GDTEST_PARSER_ERROR
+Expected expression as dictionary key.