PVS-StudioWarnings

PVS-Studio warning V557 for OpenMW

Nov 17th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. std::string rangeTypeLabel(int idx)
  2. {
  3.   const char* rangeTypeLabels [] = {
  4.     "Self",
  5.     "Touch",
  6.     "Target"
  7.   };
  8.   if (idx >= 0 && idx <= 3)
  9.     return rangeTypeLabels[idx];
  10.   else
  11.     return "Invalid";
  12. }
  13.  
  14. This suspicious code was found in OpenMW project by PVS-Studio static code analyzer.
  15. Warning message is:
  16. V557 Array overrun is possible. The value of 'idx' index could reach 3. esmtool labels.cpp 502
  17.  
  18. 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