PVS-StudioWarnings

PVS-Studio warning V528 for CxImage

Nov 13th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. int jpc_atoaf(char *s, int *numvalues, double **values)
  2. {
  3.   ...
  4.   while ((cp = strtok(0, delim))) {
  5.     if (cp != '\0') {
  6.       ++n;
  7.     }
  8.   }
  9.   ...
  10.   while ((cp = strtok(0, delim))) {
  11.     if (cp != '\0') {
  12.       vs[n] = atof(cp);
  13.       ++n;
  14.     }
  15.   }
  16.   ...
  17. }
  18.  
  19. This is an example of a Copy-Paste code with an error. This is an example of vulnerability.
  20. Pointer dereferencing is missing.
  21. This is what should have been written here: (*cp != '\0').
  22.  
  23. This suspicious code was found in CxImage project by PVS-Studio static code analyzer.
  24. Warning message is:
  25. V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant: *cp != '\0'. jasper jpc_util.c 154
  26.  
  27. 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