merge from dev-trace

This commit is contained in:
Daan Leijen 2022-04-10 13:22:35 -07:00
commit b4ca31bcd0
3 changed files with 7 additions and 7 deletions

View file

@ -116,7 +116,7 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>MI_DEBUG=3;%(PreprocessorDefinitions);</PreprocessorDefinitions> <PreprocessorDefinitions>MI_DEBUG_TRACE=1;MI_DEBUG=3;%(PreprocessorDefinitions);</PreprocessorDefinitions>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<SupportJustMyCode>false</SupportJustMyCode> <SupportJustMyCode>false</SupportJustMyCode>
<LanguageStandard>Default</LanguageStandard> <LanguageStandard>Default</LanguageStandard>

View file

@ -727,7 +727,7 @@ void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero)
const size_t start = (size >= sizeof(intptr_t) ? size - sizeof(intptr_t) : 0); const size_t start = (size >= sizeof(intptr_t) ? size - sizeof(intptr_t) : 0);
memset((uint8_t*)newp + start, 0, newsize - start); memset((uint8_t*)newp + start, 0, newsize - start);
} }
if (p != NULL) { if (mi_likely(p != NULL)) {
const size_t copysize = (newsize > size ? size : newsize); const size_t copysize = (newsize > size ? size : newsize);
if (mi_likely(((uintptr_t)p % MI_INTPTR_SIZE) == 0)) { if (mi_likely(((uintptr_t)p % MI_INTPTR_SIZE) == 0)) {
_mi_memcpy_aligned(newp, p, copysize); _mi_memcpy_aligned(newp, p, copysize);
@ -735,7 +735,7 @@ void* _mi_heap_realloc_zero(mi_heap_t* heap, void* p, size_t newsize, bool zero)
else { else {
_mi_memcpy(newp, p, copysize); _mi_memcpy(newp, p, copysize);
} }
mi_free(p); // only free the original pointer if successful mi_free(p); // only free the original pointer if successful
} }
} }
return newp; return newp;

View file

@ -27,15 +27,15 @@ int main() {
mi_version(); mi_version();
mi_stats_reset(); mi_stats_reset();
// detect double frees and heap corruption // detect double frees and heap corruption
// double_free1(); double_free1();
// double_free2(); // double_free2();
double_free3(); // double_free3();
corrupt_free1(); // corrupt_free1();
// corrupt_free2(); // corrupt_free2();
// block_overflow1(); // block_overflow1();
// block_overflow2(); // block_overflow2();
// test_aslr(); // test_aslr();
// invalid_free(); invalid_free();
// test_reserved(); // test_reserved();
// negative_stat(); // negative_stat();
// alloc_huge(); // alloc_huge();