PVS-StudioWarnings

PVS-Studio warning V512 for Snes9x

Nov 13th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. struct ICheat
  2. {
  3.   uint32  address;
  4.   uint32  new_val;
  5.   uint32  saved_val;
  6.   int     size;
  7.   bool8   enabled;
  8.   bool8   saved;
  9.   char    name [22];
  10.   int format;
  11. };
  12.  
  13. struct SCheat
  14. {
  15.   uint32 address;
  16.   uint8   byte;
  17.   uint8   saved_byte;
  18.   bool8  saved;
  19. };
  20.  
  21. void RamWatchEnableCommand(....)
  22. {
  23.   ....
  24.   struct ICheat cht;
  25.   ....
  26.   ZeroMemory(&cht, sizeof(struct SCheat));
  27.   ....
  28. }
  29.  
  30. Most likely this is what should be written here: ZeroMemory(&cht, sizeof(struct ICheat));
  31.  
  32.  
  33. This suspicious code was found in Snes9x project by PVS-Studio static code analyzer.
  34. Warning message is:
  35. V512 A call of the 'memset' function will lead to underflow of the buffer '& cht'. ramwatch.cpp 1199
  36.  
  37. 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