Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef std::basic_string<TCHAR> tstring;
- int process_report(....)
- {
- ....
- tstring sInDirName;
- ....
- size_t pos = sInDirName.rfind('\\');
- if(pos<0) // There is no back slash in path
- {
- sInDirName = _T("");
- sInFileName = szInput;
- }
- else
- {
- sInFileName = sInDirName.substr(pos+1);
- sInDirName = sInDirName.substr(0, pos);
- }
- ....
- }
- This suspicious code was found in CrashRpt project by PVS-Studio static code analyzer.
- Warning message is:
- V547 Expression 'pos < 0' is always false. Unsigned type value is never < 0. main.cpp 314
- 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