Advertisement
PVS-StudioWarnings

PVS-Studio warning V512 for ReactOS

Nov 10th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #define IsEqualGUID(rguid1, rguid2) \
  2.   (!memcmp(&(rguid1), &(rguid2), sizeof(GUID)))
  3.  
  4. static int ctl2_find_guid(....)
  5. {
  6.   MSFT_GuidEntry *guidentry;
  7.   ...
  8.   if (IsEqualGUID(guidentry, guid)) return offset;
  9.   ...
  10. }
  11.  
  12. Macros are evil! They can hide errors very well. The error is this: guidentry is a pointer.
  13. This is what should have been written here: if (IsEqualGUID(*guidentry, guid)) return offset;
  14.  
  15.  
  16. This suspicious code was found in ReactOS project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V512 A call of the 'memcmp' function will lead to underflow of the buffer 'guidentry'. oleaut32 typelib2.c 320
  19.  
  20. 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
Advertisement