Fix access order for double pointer (#13759)
authorVictor "Nate" Graf <nategraf1@gmail.com>
Tue, 5 Sep 2017 16:36:53 +0000 (09:36 -0700)
committerGitHub <noreply@github.com>
Tue, 5 Sep 2017 16:36:53 +0000 (09:36 -0700)
* Fix access order for double pointer

* Reinforce test to catch more errors

src/vm/eventpipe.cpp
tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs

index b170d4356e69fe7104eca6b8d298082a7d3a4169..57fdcd4ed8c5a9a76043705e53f90ebbdbd13e0f 100644 (file)
@@ -76,7 +76,7 @@ EventPipeEventPayload::EventPipeEventPayload(EventData **pEventData, unsigned in
     S_UINT32 tmp_size = S_UINT32(0);
     for (unsigned int i=0; i<m_eventDataCount; i++)
     {
-        tmp_size += S_UINT32(m_pEventData[i]->Size);
+        tmp_size += S_UINT32((*m_pEventData)[i].Size);
     }
 
     if (tmp_size.IsOverflow())
@@ -156,8 +156,8 @@ void EventPipeEventPayload::CopyData(BYTE *pDst)
             unsigned int offset = 0;
             for(unsigned int i=0; i<m_eventDataCount; i++)
             {
-                memcpy(pDst + offset, (BYTE*)m_pEventData[i]->Ptr, m_pEventData[i]->Size);
-                offset += m_pEventData[i]->Size;
+                memcpy(pDst + offset, (BYTE*)(*m_pEventData)[i].Ptr, (*m_pEventData)[i].Size);
+                offset += (*m_pEventData)[i].Size;
             }
         }
     }
index 16fcfc52fde17196af6c42b4720a7124b95e3512..b7d321dde6fd14d0efff334a08a101dbc6bfc951 100644 (file)
@@ -13,7 +13,7 @@ namespace Tracing.Tests
         public SimpleEventSource() : base(true) { }
 
         [Event(1)]
-        internal void Message(string msg) { this.WriteEvent(1, msg); }
+        internal void MathResult(int x, int y, int z, string formula) { this.WriteEvent(1, x, y, z, formula); }
     }
 
     class EventPipeSmoke
@@ -71,9 +71,9 @@ namespace Tracing.Tests
             {
                 int x = generator.Next(1,1000);
                 int y = generator.Next(1,1000);
-                string result = String.Format("{0} + {1} = {2}", x, y, x+y);
+                string formula = String.Format("{0} + {1} = {2}", x, y, x+y);
                 
-                eventSource.Message(result);
+                eventSource.MathResult(x, y, x+y, formula);
             }
             Console.WriteLine("\tEnd: Messaging.\n");