PVS-StudioWarnings

PVS-Studio warning V512 for Wolf

Nov 13th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. typedef struct cvar_s {
  2.   char        *name;
  3.   ...
  4.   struct cvar_s *hashNext;
  5. } cvar_t;
  6.  
  7. void Cvar_Restart_f( void ) {
  8.   cvar_t  *var;
  9.   ...
  10.   memset( var, 0, sizeof( var ) );
  11.   ...
  12. }
  13.  
  14. This is what should have been written here:
  15. memset( var, 0, sizeof( *var ) );
  16.  
  17. This suspicious code was found in Wolf project by PVS-Studio static code analyzer.
  18. Warning message is:
  19. V512 A call of the 'memset' function will lead to a buffer overflow or underflow. wolf cvar.c 764
  20.  
  21. 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