Преглед изворни кода

Merge pull request #106781 from max99x/fix-shader-crash

Fix shader compiler crash when parsing case labels with non-existent vars.
Thaddeus Crews пре 3 месеци
родитељ
комит
8c6a88cda6
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      servers/rendering/shader_language.cpp

+ 5 - 1
servers/rendering/shader_language.cpp

@@ -8532,7 +8532,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
 					DataType data_type;
 					DataType data_type;
 					bool is_const;
 					bool is_const;
 
 
-					_find_identifier(p_block, false, p_function_info, tk.text, &data_type, nullptr, &is_const);
+					bool found = _find_identifier(p_block, false, p_function_info, tk.text, &data_type, nullptr, &is_const);
+					if (!found) {
+						_set_error(vformat(RTR("Undefined identifier '%s' in a case label."), String(tk.text)));
+						return ERR_PARSE_ERROR;
+					}
 					if (is_const && data_type == p_block->expected_type) {
 					if (is_const && data_type == p_block->expected_type) {
 						correct_constant_expression = true;
 						correct_constant_expression = true;
 					}
 					}