diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 6eb7e2db04..a7260a3a1e 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -1519,7 +1519,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo encode_uint32(utf8.length(), buf); buf += 4; memcpy(buf, utf8.get_data(), utf8.length()); - buf += pad + utf8.length(); + buf += utf8.length(); + memset(buf, 0, pad); + buf += pad; } r_len += 4 + utf8.length() + pad;