Skip to content

Commit 4f53762

Browse files
Morel BérengerAntoine Fontaine
authored andcommitted
InternalRecvMsg reserves before pushing
1 parent 4ac6034 commit 4f53762

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
@@ -361,6 +361,8 @@ bool InternalRecvMsg(Sys::OSHandle handle, Util::Reader& reader)
361361
if (hdr.flags & (NACL_MESSAGE_TRUNCATED | NACL_HANDLES_TRUNCATED))
362362
Sys::Drop("IPC: Recieved truncated message");
363363

364+
// NACL_ABI_IMC_DESC_MAX == 8 anyway, so let's avoid useless loops and reallocs
365+
reader.GetHandles().reserve(reader.GetHandles().size() + NACL_ABI_IMC_DESC_MAX);
364366
for (size_t i = 0; i < NACL_ABI_IMC_DESC_MAX; i++) {
365367
if (h[i] != NACL_INVALID_HANDLE) {
366368
reader.GetHandles().emplace_back();

0 commit comments

Comments
 (0)