From 33fd7c63e1dd897da367322c4ab4e04ae2658750 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Mon, 27 Jun 2022 19:02:42 -0700 Subject: Prevent out-of-bounds write in array conversion; avoid logspam on empty arrays. --- core/templates/vector.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core/templates') 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 to_byte_array() const { Vector ret; + if (is_empty()) { + return ret; + } ret.resize(size() * sizeof(T)); memcpy(ret.ptrw(), ptr(), sizeof(T) * size()); return ret; -- cgit v1.2.3