Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays.

This commit is contained in:
Lyuma
2022-06-27 19:02:42 -07:00
parent b863c40356
commit 33fd7c63e1
3 changed files with 32 additions and 13 deletions

View File

@ -145,6 +145,9 @@ public:
Vector<uint8_t> to_byte_array() const {
Vector<uint8_t> ret;
if (is_empty()) {
return ret;
}
ret.resize(size() * sizeof(T));
memcpy(ret.ptrw(), ptr(), sizeof(T) * size());
return ret;