Skip to content

Commit d7a72c4

Browse files
author
daanx
committed
fix thread data leak; issue #748
1 parent 86d1585 commit d7a72c4

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
@@ -175,9 +175,9 @@ mi_heap_t* _mi_heap_main_get(void) {
175175

176176
// note: in x64 in release build `sizeof(mi_thread_data_t)` is under 4KiB (= OS page size).
177177
typedef struct mi_thread_data_s {
178-
mi_heap_t heap; // must come first due to cast in `_mi_heap_done`
178+
mi_heap_t heap; // must come first due to cast in `_mi_heap_done`
179179
mi_tld_t tld;
180-
mi_memid_t memid;
180+
mi_memid_t memid; // must come last due to zero'ing
181181
} mi_thread_data_t;
182182

183183

@@ -223,7 +223,7 @@ static mi_thread_data_t* mi_thread_data_zalloc(void) {
223223
}
224224

225225
if (td != NULL && !is_zero) {
226-
_mi_memzero_aligned(td, sizeof(*td));
226+
_mi_memzero_aligned(td, offsetof(mi_thread_data_t,memid));
227227
}
228228
return td;
229229
}

0 commit comments

Comments
 (0)