PVS-StudioWarnings

PVS-Studio warning V557 for Notepad++

Nov 18th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. int encodings[] = {
  2.   1250,
  3.   1251,
  4.   1252,
  5.   ....
  6. };
  7.  
  8. BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(
  9.   UINT Message, WPARAM wParam, LPARAM)
  10. {
  11.   ...
  12.   for (int i = 0 ; i <= sizeof(encodings)/sizeof(int) ; i++)
  13.   {
  14.     int cmdID = em->getIndexFromEncoding(encodings[i]);
  15.   ...
  16. }
  17.  
  18. This is what should have been written here: i < sizeof(encodings)/sizeof(int)
  19.  
  20. This suspicious code was found in Notepad++ project by PVS-Studio static code analyzer.
  21. Warning message is:
  22. V557 Array overrun is possible. The value of 'i' index could reach 46.  Notepad++  preferencedlg.cpp  984
  23.  
  24. 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