From f388d2362a5aabfe8abe6562690da18d902346ba Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 30 Sep 2023 09:33:11 +0200 Subject: [PATCH] LibJS: Pad the capacity of BasicBlock while growing it Just using Vector::resize() meant that we allocated exact capacity instead of leaving padding at the end. This patch adds a call to grow_capacity() before resize(), which ensures that we grow with the usual extra padding. --- Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp b/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp index fe94e33986..8a931e0e62 100644 --- a/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp +++ b/Userland/Libraries/LibJS/Bytecode/BasicBlock.cpp @@ -43,6 +43,7 @@ void BasicBlock::dump(Bytecode::Executable const& executable) const void BasicBlock::grow(size_t additional_size) { + m_buffer.grow_capacity(m_buffer.size() + additional_size); m_buffer.resize(m_buffer.size() + additional_size); }