summaryrefslogtreecommitdiff
path: root/src/vm/eventpipeblock.h
diff options
context:
space:
mode:
authorAndrew Au <andrewau@microsoft.com>2019-05-08 10:35:43 -0700
committerAndrew Au <cshung@gmail.com>2019-05-08 23:51:05 -0700
commit29df4e8218ee7d147542f767d899c5c639932e06 (patch)
tree80dfe8cf9c77b815fe381d25a39e8078c284f9a0 /src/vm/eventpipeblock.h
parent597e5faa03773e3140850d16381c00a6f9d20335 (diff)
downloadcoreclr-29df4e8218ee7d147542f767d899c5c639932e06.tar.gz
coreclr-29df4e8218ee7d147542f767d899c5c639932e06.tar.bz2
coreclr-29df4e8218ee7d147542f767d899c5c639932e06.zip
Return the required padding size instead of the current position to avoid integer overflow.
Diffstat (limited to 'src/vm/eventpipeblock.h')
-rw-r--r--src/vm/eventpipeblock.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/vm/eventpipeblock.h b/src/vm/eventpipeblock.h
index 78b04af805..c85a84e461 100644
--- a/src/vm/eventpipeblock.h
+++ b/src/vm/eventpipeblock.h
@@ -51,14 +51,13 @@ public:
if (eventsSize == 0)
return;
- size_t currentPosition = pSerializer->GetCurrentPosition();
- if (currentPosition % ALIGNMENT_SIZE != 0)
+ unsigned int requiredPadding = pSerializer->GetRequiredPadding();
+ if (requiredPadding != 0)
{
BYTE maxPadding[ALIGNMENT_SIZE - 1] = {}; // it's longest possible padding, we are going to use only part of it
- unsigned int paddingLength = ALIGNMENT_SIZE - (currentPosition % ALIGNMENT_SIZE);
- pSerializer->WriteBuffer(maxPadding, paddingLength); // we write zeros here, the reader is going to always read from the first aligned address of the serialized content
+ pSerializer->WriteBuffer(maxPadding, requiredPadding); // we write zeros here, the reader is going to always read from the first aligned address of the serialized content
- _ASSERTE(pSerializer->HasWriteErrors() || (pSerializer->GetCurrentPosition() % ALIGNMENT_SIZE == 0));
+ _ASSERTE(pSerializer->HasWriteErrors() || (pSerializer->GetRequiredPadding() == 0));
}
pSerializer->WriteBuffer(m_pBlock, eventsSize);