From 251cec24353161b1183d4a630c22a5e5b268e71d Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:53:28 +0100 Subject: [PATCH] Prevent encoding objects that cannot be instantiated --- core/io/marshalls.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 3d384d9345b9eb..bc2493d3600072 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -638,6 +638,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int if (str.is_empty()) { r_variant = (Object *)nullptr; } else { + ERR_FAIL_COND_V(!ClassDB::can_instantiate(str), ERR_INVALID_DATA); + Object *obj = ClassDB::instantiate(str); ERR_FAIL_NULL_V(obj, ERR_UNAVAILABLE); @@ -1492,6 +1494,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4; } else { + ERR_FAIL_COND_V(!ClassDB::can_instantiate(obj->get_class()), ERR_INVALID_PARAMETER); + _encode_string(obj->get_class(), buf, r_len); List props;