Advertisement
PVS-StudioWarnings

PVS-Studio warning V557 for Source SDK

Nov 21st, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #define MAX_WEAPON_SLOTS    6  // hud item selection slots
  2.  
  3. void CHudWeaponSelection::Paint()
  4. {
  5.   ....
  6.   int xModifiers[] = { 0, 1, 0, -1 };
  7.   int yModifiers[] = { -1, 0, 1, 0 };
  8.  
  9.   for ( int i = 0; i < MAX_WEAPON_SLOTS; ++i )
  10.   {
  11.     ....
  12.     xPos += ( m_flMediumBoxWide + 5 ) * xModifiers[ i ];
  13.     yPos += ( m_flMediumBoxTall + 5 ) * yModifiers[ i ];
  14.   ....
  15. }
  16.  
  17. This suspicious code was found in Source SDK project by PVS-Studio static code analyzer.
  18. Warning message is:
  19. V557 Array overrun is possible. The value of 'i' index could reach 5. Client (HL2) hud_weaponselection.cpp 632
  20.  
  21. 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