PVS-StudioWarnings

PVS-Studio warning V557 for Firefox

Nov 17th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. class nsBaseStatis : public nsStatis {
  2. public:
  3.   ...
  4.   PRUint32 mLWordLen[10];
  5.   ...
  6.   nsBaseStatis::nsBaseStatis(
  7.     unsigned char aL, unsigned char aH, float aR)
  8.   {
  9.     ...
  10.     for(PRUint32 i = 0; i < 20; i++)
  11.        mLWordLen[i] = 0;
  12.     ...
  13.   }
  14. }
  15.  
  16.   ...
  17. };
  18.  
  19. This is what should have been written here: for(PRUint32 i = 0; i < 10; i++) or: for(PRUint32 i = 0; i < sizeof(mLWordLen)/sizeof(mLWordLen[0]); i++)
  20.  
  21. This suspicious code was found in Firefox project by PVS-Studio static code analyzer.
  22. Warning message is:
  23. V557 Array overrun is possible. The value of 'i' index could reach 19. detectcharset.cpp 89
  24.  
  25. 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