PVS-StudioWarnings

PVS-Studio warning V557 for Geant4

Nov 19th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. enum { NENERGY=22, NANGLE=180 };
  2.  
  3. class G4LEpp : public G4HadronicInteraction
  4. {
  5.   ....
  6.   G4float * sig[NANGLE];
  7.   static G4float SigCoul[NENERGY][NANGLE];
  8.   ....
  9. };
  10.  
  11. G4LEpp::SetCoulombEffects(G4int State)
  12. {
  13.   if (State) {
  14.     for(G4int i=0; i<NANGLE; i++)
  15.     {
  16.       sig[i] = SigCoul[i];
  17.     }
  18.     elab = ElabCoul;
  19.   }
  20.   ....
  21. }
  22.  
  23. This suspicious code was found in Geant4 project by PVS-Studio static code analyzer.
  24. Warning message is:
  25. V557 Array overrun is possible. The value of 'i' index could reach 179. g4lepp.cc 62
  26.  
  27. 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