PVS-StudioWarnings

PVS-Studio warning V503 for xpdfwin

Nov 20th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. char* stringarray_at(stringarray_t*sa, int pos)
  2. {
  3.   stringarray_internal_t*s =
  4.     (stringarray_internal_t*)sa->internal;
  5.   char *p;
  6.   if (pos<0 || pos>=s->num)
  7.     return 0;
  8.  
  9.   p = *(char**)&s->pos.buffer[pos*sizeof(char*)];
  10.  
  11.   if(p<0)  <<<---
  12.     return 0;
  13.  
  14.   return p;
  15. }
  16.  
  17. This suspicious code was found in xpdfwin project by PVS-Studio static code analyzer.
  18. Warning message is:
  19. V503 This is a nonsensical comparison: pointer < 0. pdf2swf q.c 804
  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