PVS-StudioWarnings

PVS-Studio warning V557 for FlightGear

Nov 18th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. enum {
  2.   ALL_EJECTION_SEATS = -1,
  3.   MAX_EJECTION_SEATS = 10
  4. };
  5.  
  6. int eseat_status[MAX_EJECTION_SEATS];
  7.  
  8. void
  9. FGControls::set_ejection_seat( int which_seat, bool val )
  10. {
  11.   ....
  12.   if ((which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS))
  13.   {
  14.     if ( eseat_status[which_seat] == SEAT_SAFED ||
  15.          eseat_status[which_seat] == SEAT_FAIL )
  16.   ....
  17. }
  18.  
  19. This suspicious code was found in FlightGear project by PVS-Studio static code analyzer.
  20. Warning message is:
  21. V557 Array overrun is possible. The value of 'which_seat' index could reach 10. controls.cxx 1717
  22.  
  23. 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