Merge pull request #84155 from AThousandShips/encode_fix

Prevent `encode_variant` doing `memcpy` from `nullptr`
This commit is contained in:
Rémi Verschelde 2023-10-30 23:19:22 +01:00
commit a3e4c4f41c
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -1621,8 +1621,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
encode_uint32(datalen, buf);
buf += 4;
const uint8_t *r = data.ptr();
memcpy(buf, &r[0], datalen * datasize);
buf += datalen * datasize;
if (r) {
memcpy(buf, &r[0], datalen * datasize);
buf += datalen * datasize;
}
}
r_len += 4 + datalen * datasize;