PVS-StudioWarnings

PVS-Studio warning V512 for MAME

Nov 12th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. UINT16 m_control_0[8];
  2. #define ARRAY_LENGTH(x)  (sizeof(x) / sizeof(x[0]))
  3.  
  4. static MACHINE_RESET( tumbleb )
  5. {
  6.   ...
  7.   memset(state->m_control_0, 0,
  8.          ARRAY_LENGTH(state->m_control_0));
  9. }
  10.  
  11. Most likely this is what should be written here: memset(state->m_control_0, 0, sizeof(state->m_control_0));
  12.  
  13.  
  14. This suspicious code was found in MAME project by PVS-Studio static code analyzer.
  15. Warning message is:
  16. V512 A call of the 'memset' function will lead to underflow of the buffer 'state->m_control_0'.  tumbleb.c 2065
  17.  
  18. 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