Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String GetSysError(int nerr);
- ...
- CString msg;
- msg.Format(
- _T("Failed to open registry key HKCU/%s:\n\t%d : %s"),
- f_RegDir, retVal, GetSysError(retVal));
- Everything looks fine at the first sight. But the "String" type is nothing but "std::wstring". Therefore, we will get some gibberish printed at best and an Access Violation error at worst. An object of the "std::wstring" type is placed instead of the string pointer into the stack. The correct code should contain a call of c_str():
- This suspicious code was found in WinMerge project by PVS-Studio static code analyzer.
- Warning message is:
- V510 The 'Format' function is not expected to receive class-type variable as 'N' actual argument
- PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement