From a3cf23c19fff6fd34492bee85788f2e52e41531b Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Mon, 26 Jul 2021 19:10:21 -0700 Subject: [PATCH] add test for #445 --- test/main-override.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/main-override.cpp b/test/main-override.cpp index 5fe3f9a3..d7663330 100644 --- a/test/main-override.cpp +++ b/test/main-override.cpp @@ -34,6 +34,7 @@ void various_tests(); void test_mt_shutdown(); void fail_aslr(); // issue #372 void tsan_numa_test(); // issue #414 +void strdup_test(); // issue #445 int main() { mi_stats_reset(); // ignore earlier allocations @@ -43,6 +44,7 @@ int main() { padding_shrink(); various_tests(); tsan_numa_test(); + strdup_test(); //test_mt_shutdown(); //fail_aslr(); @@ -74,18 +76,13 @@ void various_tests() { p1 = malloc(8); char* s = mi_strdup("hello\n"); - //char* s = _strdup("hello\n"); - //char* buf = NULL; - //size_t len; - //_dupenv_s(&buf,&len,"MIMALLOC_VERBOSE"); - //mi_free(buf); - mi_free(p2); p2 = malloc(16); p1 = realloc(p1, 32); free(p1); free(p2); mi_free(s); + Test* t = new Test(42); delete t; t = new (std::nothrow) Test(42); @@ -125,7 +122,17 @@ bool test_stl_allocator2() { return vec.size() == 0; } - +// issue 445 +static void strdup_test() { +#ifdef _MSC_VER + char* s = _strdup("hello\n"); + char* buf = NULL; + size_t len; + _dupenv_s(&buf, &len, "MIMALLOC_VERBOSE"); + mi_free(buf); + mi_free(s); +#endif +} // Issue #202 void heap_no_delete_worker() {