Skip to content

Commit f22e047

Browse files
committed
fix windows test to use strcpy_s instead of strlcpy
1 parent e504759 commit f22e047

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ mi_decl_noinline static void mi_tld_free(mi_tld_t* tld) {
384384
if (tld==NULL || tld==MI_TLD_INVALID) return;
385385
mi_atomic_decrement_relaxed(&tld->subproc->thread_count);
386386
tld->thread_id = MI_THREADID_INVALID; // note: not 0 as that would re-initialize tld_main
387+
// we also need to set an invalid tid for tld_main as sometimes the same thread-id
388+
// is reused by the OS after a thread has terminated. (see issue #1287)
387389
mi_lock_done(&tld->theaps_lock);
388390
_mi_meta_free(tld, sizeof(mi_tld_t), tld->memid); // note: safe for static tld_main
389391
}

test/main-static-dep.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ static Static s = Static();
2424

2525
void Test(void) {
2626
char* s = mi_mallocn_tp(char, 128);
27+
#ifdef _WIN32
28+
strcpy_s(s, 128, "hello world!");
29+
#else
2730
strlcpy(s, "hello world!", 128);
31+
#endif
2832
printf("message from static dll: %s\n", s);
2933
mi_free(s);
3034
}

0 commit comments

Comments
 (0)