PVS-StudioWarnings

PVS-Studio warning V557 for cmake

Nov 11th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. static const struct {
  2.     DWORD       winerr;
  3.     int     doserr;
  4. } doserrors[] =
  5. {
  6.   ...
  7. };
  8.  
  9. static void
  10. la_dosmaperr(unsigned long e)
  11. {
  12.   ...
  13.   for (i = 0; i < sizeof(doserrors); i++)
  14.   {
  15.     if (doserrors[i].winerr == e)
  16.     {
  17.       errno = doserrors[i].doserr;
  18.       return;
  19.     }
  20.   }
  21.   ...
  22. }
  23.  
  24. This is what should have been written here: sizeof(doserrors) / sizeof(*doserrors)
  25.  
  26. This suspicious code was found in cmake project by PVS-Studio static code analyzer.
  27. Warning message is:
  28. V557 Array overrun is possible. The value of 'i' index could reach 367. cmlibarchive archive_windows.c 1140
  29.  
  30. 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