Kaynağa Gözat

GDSript: Prevent crash when completing unary operators

George Marques 5 yıl önce
ebeveyn
işleme
f374021d52
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  1. 6 0
      modules/gdscript/gdscript_analyzer.cpp

+ 6 - 0
modules/gdscript/gdscript_analyzer.cpp

@@ -2509,6 +2509,12 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op)
 
 
 	GDScriptParser::DataType result;
 	GDScriptParser::DataType result;
 
 
+	if (p_unary_op->operand == nullptr) {
+		result.kind = GDScriptParser::DataType::VARIANT;
+		p_unary_op->set_datatype(result);
+		return;
+	}
+
 	if (p_unary_op->operand->is_constant) {
 	if (p_unary_op->operand->is_constant) {
 		p_unary_op->is_constant = true;
 		p_unary_op->is_constant = true;
 		p_unary_op->reduced_value = Variant::evaluate(p_unary_op->variant_op, p_unary_op->operand->reduced_value, Variant());
 		p_unary_op->reduced_value = Variant::evaluate(p_unary_op->variant_op, p_unary_op->operand->reduced_value, Variant());