diff options
author | Lyuma <xn.lyuma@gmail.com> | 2022-06-27 19:02:42 -0700 |
---|---|---|
committer | Lyuma <xn.lyuma@gmail.com> | 2022-06-30 18:04:33 -0700 |
commit | 33fd7c63e1dd897da367322c4ab4e04ae2658750 (patch) | |
tree | 1ada6e10e7caace006617fe7e22c0d314bff00d5 /core/templates | |
parent | b863c40356b4b95192d1a1e2718db7d7aced4235 (diff) |
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; |