All memory allocated by the C runtime in a dll is freed too early by __freeCrtMemory()._ioterm() and _mtterm() which are called after __freeCrtMemory() both access and/or free memory that was allocated by the C runtime. See below: /* Free allocated CRT memory */ __freeCrtMemory();#ifndef _DEBUG /* If dwReason is DLL_PROCESS_DETACH, lpreserved is NULL * if FreeLibrary has been called or the DLL load failed * and non-NULL if the process is terminating. */ if ( lpreserved == NULL ) {#endif /* _DEBUG */ /* * The process is NOT terminating so we must clean up... */ /* Shut down lowio */ _ioterm(); _mtterm(); /* This should be the last thing the C run-time does */ _heap_term(); /* heap is now invalid! */#ifndef _DEBUG }#endif /* _DEBUG */The fix is simple. __freeCrtMemory() should be after _mtterm().
Visual Studio/Team Foundation Server/.NET Framework Tooling Version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results