Fix issue 23037
authorAndrew Au <andrewau@microsoft.com>
Tue, 5 Mar 2019 20:01:15 +0000 (12:01 -0800)
committerAndrew Au <cshung@gmail.com>
Wed, 6 Mar 2019 01:29:03 +0000 (17:29 -0800)
src/vm/eventpipebuffer.cpp

index 1149427..c513df4 100644 (file)
@@ -67,12 +67,12 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve
         return false;
     }
 
-    // Calculate the location of the data payload.
-    BYTE *pDataDest = m_pCurrent + sizeof(EventPipeEventInstance);
-
     bool success = true;
     EX_TRY
     {
+        // Calculate the location of the data payload.
+        BYTE *pDataDest = payload.GetSize() == 0 ? NULL : m_pCurrent + sizeof(EventPipeEventInstance);
+
         // Placement-new the EventPipeEventInstance.
         // if pthread is NULL, it's likely we are running in something like a GC thread which is not a Thread object, so it can't have an activity ID set anyway
         EventPipeEventInstance *pInstance = new (m_pCurrent) EventPipeEventInstance(
@@ -83,7 +83,6 @@ bool EventPipeBuffer::WriteEvent(Thread *pThread, EventPipeSession &session, Eve
             payload.GetSize(),
             (pThread == NULL) ? NULL : pActivityId,
             pRelatedActivityId);
-       
 
         // Copy the stack if a separate stack trace was provided.
         if(pStack != NULL)