Skip to content

Commit 87c2410

Browse files
committed
add extra NULL initialization on Windows TLS allocation (issue #1324)
1 parent 59d9fd8 commit 87c2410

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,12 +806,14 @@ static bool mi_win_tls_slot_alloc(size_t* slot, size_t* extended, DWORD* raw_ind
806806
return false;
807807
}
808808
else if (index<MI_TLS_DIRECT_SLOTS) {
809+
TlsSetValue(index,NULL);
809810
*extended = 0;
810811
*slot = index + MI_TLS_DIRECT_FIRST;
811812
return true;
812813
}
813814
#if !MI_WIN_DIRECT_TLS
814815
else if (index < MI_TLS_DIRECT_SLOTS + MI_TLS_EXPANSION_SLOTS - 1) { // check maximum number of expansion slots - 1 (as we use the last one as the default)
816+
TlsSetValue(index,NULL);
815817
*extended = index - MI_TLS_DIRECT_SLOTS;
816818
*slot = MI_TLS_EXPANSION_SLOT;
817819
return true;
@@ -830,6 +832,7 @@ static bool mi_win_tls_slot_alloc(size_t* slot, size_t* extended, DWORD* raw_ind
830832

831833
static void mi_win_tls_slot_free(DWORD* raw_index) {
832834
if (*raw_index != TLS_OUT_OF_INDEXES) {
835+
TlsSetValue(*raw_index,NULL);
833836
TlsFree(*raw_index);
834837
*raw_index = TLS_OUT_OF_INDEXES;
835838
}

0 commit comments

Comments
 (0)