From 3567f31725bbd35ebec55023d17410b8e0404611 Mon Sep 17 00:00:00 2001 From: Saagar Jha Date: Sat, 22 Aug 2026 01:37:55 -0700 Subject: [PATCH] Fix a leak in BinaryReader::ReadVector The new behavior requires that T is value initializable but generally you have no business calling this function if that is not the case, so this should be fine. --- binaryreader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/binaryreader.cpp b/binaryreader.cpp index b8ae0cc824..48c7394527 100644 --- a/binaryreader.cpp +++ b/binaryreader.cpp @@ -489,10 +489,9 @@ T BinaryReader::Read() template vector BinaryReader::ReadVector(size_t count) { - T* buff = new T[count]; - Read((char*)buff, count * sizeof(T)); - std::vector out(buff, buff + count); - return out; + auto result = std::vector(count); + Read(reinterpret_cast(result.data()), result.size() * sizeof(T)); + return result; }