Skip to content

Commit 5940037

Browse files
Morel BérengerAntoine Fontaine
authored andcommitted
InternalRecvMsg reserves before pushing
1 parent deae102 commit 5940037

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/common/IPC/Primitives.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ bool InternalRecvMsg(Sys::OSHandle handle, Util::Reader& reader)
365365
if (hdr.flags & (NACL_MESSAGE_TRUNCATED | NACL_HANDLES_TRUNCATED))
366366
Sys::Drop("IPC: Recieved truncated message");
367367

368+
// NACL_ABI_IMC_DESC_MAX == 8 anyway, so let's avoid useless loops and reallocs
369+
reader.GetHandles().reserve(reader.GetHandles().size() + NACL_ABI_IMC_DESC_MAX);
368370
for (size_t i = 0; i < NACL_ABI_IMC_DESC_MAX; i++) {
369371
if (h[i] != NACL_INVALID_HANDLE) {
370372
reader.GetHandles().emplace_back();

0 commit comments

Comments
 (0)