diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2020-12-17 13:15:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 13:15:08 +0100 |
commit | f47ef030d072881b8396593606e50a206a5e54a6 (patch) | |
tree | cf04ff171620d29bf43e87070d1eba6cacb42574 /core/variant | |
parent | e61f5867e804eb272002244289a8c17b2252af76 (diff) | |
parent | 1b745c7baeddd4589a447549fcdc5630ea767407 (diff) |
Merge pull request #44452 from RandomShaper/fix_crash_parsing_ref
Fix crash parsing a serialized Reference
Diffstat (limited to 'core/variant')
-rw-r--r-- | core/variant/variant_parser.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp index 5a0bbf041b..00d81f597a 100644 --- a/core/variant/variant_parser.cpp +++ b/core/variant/variant_parser.cpp @@ -743,6 +743,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, return ERR_PARSE_ERROR; } + REF ref = REF(Object::cast_to<Reference>(obj)); + get_token(p_stream, token, line, r_err_str); if (token.type != TK_COMMA) { r_err_str = "Expected ',' after object type"; @@ -767,12 +769,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, } if (token2.type == TK_PARENTHESIS_CLOSE) { - Reference *reference = Object::cast_to<Reference>(obj); - if (reference) { - value = REF(reference); - } else { - value = obj; - } + value = ref.is_valid() ? Variant(ref) : Variant(obj); return OK; } |