PVS-StudioWarnings

PVS-Studio warning V510 for TortoiseSVN

Nov 21st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. string CExceptionReport::getCrashLog()
  2. {
  3.   ...
  4.   _tprintf_s(buf, _T("%s\\%s.xml"),
  5.   getenv("TEMP"), CUtility::getAppName());
  6.   ...
  7. }
  8.  
  9. The V510 message warns you that it's a bad idea to pass a parameter of the std::string type into the printf_s function.
  10. And it is std::string that the CUtility::getAppName() function returns. The error is this: the programmer forgot to write ".c_str()". It may result both in incorrect data output and program crash.
  11.  
  12. This suspicious code was found in TortoiseSVN project by PVS-Studio static code analyzer.
  13. Warning message is:
  14. V510 The 'printf_s' function is not expected to receive class-type variable as fourth actual argument. excprpt.cpp 199
  15.  
  16. 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