diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-07-01 09:03:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-01 09:03:20 +0200 |
commit | 88192269a8ae84d1f5f15bbe6d91438ecd93bad4 (patch) | |
tree | 86ded1300feae049a24adca4e7f266f233d44a70 /core/templates | |
parent | afdae67cc381bb340da2e864279da6b836804b7f (diff) | |
parent | 33fd7c63e1dd897da367322c4ab4e04ae2658750 (diff) |
Merge pull request #62477 from lyuma/packedbytearray
Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays.
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/vector.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/templates/vector.h b/core/templates/vector.h index 2ac7c7630a..f3f5ed76a7 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -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; |