PVS-StudioWarnings

PVS-Studio warning V557 for ITK

Nov 20th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #define MET_NUM_VALUE_TYPES 29
  2.  
  3. const char MET_ValueTypeName[MET_NUM_VALUE_TYPES][21] = { ... };
  4.  
  5. bool MET_TypeToString(MET_ValueEnumType _vType, char *_s)
  6. {
  7.   if(_vType>=0 && _vType<=MET_NUM_VALUE_TYPES)
  8.     {
  9.     strcpy(_s, MET_ValueTypeName[_vType]);
  10.     return true;
  11.     }
  12.  
  13.   return false;
  14. }
  15.  
  16. This suspicious code was found in ITK project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V557 Array overrun is possible. The value of '_vType' index could reach 29. metautils.cxx 239
  19.  
  20. 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