Skip to content

Commit 16e6e95

Browse files
authored
EventPipe C library CoreClr ep_rt_object_array_alloc should zero init. (#47111)
EventPipe C library is defensive in its type allocators: ep_rt_object_alloc ep_rt_object_array_alloc meaning that they will zero init memory before returned. On Mono this is done through use of g_new0 and on CoreClr we use C++11 zero init feature when allocating struct (only type allocated through these functions). On CoreClr this was only applied for ep_rt_object_alloc but not for ep_rt_object_array_alloc meaning that ep_rt_object_array_alloc would return arrays of allocated objects but not zero initialized. PR makes sure we call new (nothrow) utilizing C++11's zero initialization capabilities of non-class types without constructors.
1 parent ed5137a commit 16e6e95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ ep_rt_execute_rundown (void)
18911891

18921892
// STATIC_CONTRACT_NOTHROW
18931893
#undef ep_rt_object_array_alloc
1894-
#define ep_rt_object_array_alloc(obj_type,size) (new (nothrow) obj_type [size])
1894+
#define ep_rt_object_array_alloc(obj_type,size) (new (nothrow) obj_type [size]())
18951895

18961896
// STATIC_CONTRACT_NOTHROW
18971897
#undef ep_rt_object_array_free

0 commit comments

Comments
 (0)