PVS-StudioWarnings

PVS-Studio warning V547 for TortoiseSVN

Nov 21st, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. typedef index_t revision_t;
  2. ...
  3. void CCacheLogQuery::InternalLog (
  4.    revision_t startRevision
  5.  , revision_t endRevision
  6.  , const CDictionaryBasedTempPath& startPath
  7.  , int limit
  8.  , const CLogOptions& options)
  9. {
  10.   ...
  11.   // we cannot receive logs for rev < 0
  12.   if (endRevision < 0)
  13.     endRevision = 0;
  14.  
  15.   ...
  16. }
  17.  
  18. Negative values simply cannot appear here. The endRevision variable has the unsigned type and, therefore, endRevision is always >=0. The potential danger is this: if a negative value was cast to the unsigned type somewhere before, we will be handling a very big number. And there's no check for that.
  19.  
  20. This suspicious code was found in TortoiseSVN project by PVS-Studio static code analyzer.
  21. Warning message is:
  22. V547 Expression 'endRevision < 0' is always false. Unsigned type value is never < 0. cachelogquery.cpp 999
  23.  
  24. 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