This project has moved and is read-only. For the latest updates, please go here.

Found an error of source code

Jun 8, 2011 at 7:45 AM

file: vld.cpp

function: BOOL VisualLeakDetector::addloadedmodule (PCWSTR modulepath, DWORD64 modulebase, ULONG modulesize, PVOID context)

error :   In my computer, use old codes,  "WideCharToMultiByte" return 0

should: 

 {

 // Convert the module path to ASCII.
 size_t length = ::WideCharToMultiByte(CP_ACP, 0, modulepath, -1, 0, 0, 0, 0);
 //size_t length = wcslen(modulepath) + 1;
    LPSTR modulepatha = new CHAR [length];

    // wcstombs_s requires locale to be already set up correctly, but it might not be correct on vld init step. So use WideCharToMultiByte instead
    CHAR defaultChar     = '?';
    BOOL defaultCharUsed = FALSE;

    int count = ::WideCharToMultiByte(CP_ACP, 0/*flags*/, modulepath, (int)-1, modulepatha, (int)length, &defaultChar, &defaultCharUsed);

    .....

}

Jun 8, 2011 at 1:15 PM

Thank you. Fixed.