From 4dafa5b21ef93dc6a4c05bb190d2e1a172063a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Thu, 17 Dec 2020 12:24:55 +0100 Subject: [PATCH] Fix crash parsing a serialized Reference --- core/variant_parser.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 80e845ad6e8..dde23fd55ae 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -712,6 +712,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return ERR_PARSE_ERROR; } + REF ref = REF(Object::cast_to(obj)); + get_token(p_stream, token, line, r_err_str); if (token.type != TK_COMMA) { r_err_str = "Expected ',' after object type"; @@ -737,12 +739,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return err; if (token2.type == TK_PARENTHESIS_CLOSE) { - Reference *reference = Object::cast_to(obj); - if (reference) { - value = REF(reference); - } else { - value = obj; - } + value = ref.is_valid() ? Variant(ref) : Variant(obj); return OK; }