PVS-StudioWarnings

PVS-Studio warning V522 for GeoLib

Nov 11th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. void WINAPI _GetMonitorRectByIndex( int iMonitor, RECT* pRect )
  2. {
  3.  int iMonitorCount = ::GetSystemMetrics( SM_CMONITORS );
  4.  
  5.  if ( iMonitor <= iMonitorCount || pRect != NULL ) <<<---
  6.  {
  7.   if ( iMonitorCount == 1 )
  8.   {
  9.     pRect->left = 0;
  10.     pRect->top = 0;
  11.     pRect->right = GetSystemMetrics( SM_CXSCREEN );
  12.     pRect->bottom = GetSystemMetrics( SM_CYSCREEN );
  13.   }
  14.   ...
  15.  }
  16.  else
  17.  {
  18.    pRect->left   = -1;   <<<---
  19.    pRect->top    = -1;
  20.    pRect->right  = -1;
  21.    pRect->bottom = -1;
  22.  }
  23. }
  24.  
  25. This suspicious code was found in GeoLib project by PVS-Studio static code analyzer.
  26. Warning message is:
  27. V522 Dereferencing of the null pointer 'pRect' might take place. geOLib geolib.cpp 3282
  28.  
  29. 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