Merge pull request #44453 from RandomShaper/fix_crash_parsing_ref_3.2

Fix crash parsing a serialized Reference (3.2)
This commit is contained in:
Rémi Verschelde 2020-12-17 13:15:15 +01:00 committed by GitHub
commit 3f47cdc5c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -712,6 +712,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
REF ref = REF(Object::cast_to<Reference>(obj));
get_token(p_stream, token, line, r_err_str); get_token(p_stream, token, line, r_err_str);
if (token.type != TK_COMMA) { if (token.type != TK_COMMA) {
r_err_str = "Expected ',' after object type"; r_err_str = "Expected ',' after object type";
@ -737,12 +739,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return err; return err;
if (token2.type == TK_PARENTHESIS_CLOSE) { if (token2.type == TK_PARENTHESIS_CLOSE) {
Reference *reference = Object::cast_to<Reference>(obj); value = ref.is_valid() ? Variant(ref) : Variant(obj);
if (reference) {
value = REF(reference);
} else {
value = obj;
}
return OK; return OK;
} }