PVS-StudioWarnings

PVS-Studio warning V512 for DeSmuME

Nov 12th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. mapview_struct *MapView = NULL;
  2.  
  3. BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message,
  4.                             WPARAM wParam, LPARAM lParam)
  5. {
  6.   ...
  7.   MapView = new mapview_struct;
  8.   memset(MapView, 0, sizeof(MapView));
  9.   ...
  10. }
  11.  
  12. This is what should have been written here:
  13. memset(MapView, 0, sizeof(*MapView));
  14.  
  15. This suspicious code was found in DeSmuME project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V512 A call of the 'memset' function will lead to underflow of the buffer 'MapView'. DeSmuME_VS2005 mapview.cpp 204
  18.  
  19. 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