Skip to content

Commit 315650d

Browse files
daanxCristian Silaghi
authored andcommitted
fix thread data leak; issue microsoft#748
1 parent 61dc4db commit 315650d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/init.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ mi_heap_t* _mi_heap_main_get(void) {
201201

202202
// note: in x64 in release build `sizeof(mi_thread_data_t)` is under 4KiB (= OS page size).
203203
typedef struct mi_thread_data_s {
204-
mi_heap_t heap; // must come first due to cast in `_mi_heap_done`
204+
mi_heap_t heap; // must come first due to cast in `_mi_heap_done`
205205
mi_tld_t tld;
206-
mi_memid_t memid;
206+
mi_memid_t memid; // must come last due to zero'ing
207207
} mi_thread_data_t;
208208

209209

@@ -249,7 +249,7 @@ static mi_thread_data_t* mi_thread_data_zalloc(void) {
249249
}
250250

251251
if (td != NULL && !is_zero) {
252-
_mi_memzero_aligned(td, sizeof(*td));
252+
_mi_memzero_aligned(td, offsetof(mi_thread_data_t,memid));
253253
}
254254
return td;
255255
}

0 commit comments

Comments
 (0)