PVS-StudioWarnings

PVS-Studio warning V514 for Scilab

Nov 18th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. void qsort(
  2.   void *base,
  3.   size_t num,     // Array size in elements.
  4.   size_t width,   // Element size in bytes.
  5.   int (__cdecl *compare )(const void *, const void *)
  6. );
  7.  
  8. char *getCommonPart(char **dictionary, int sizeDictionary)
  9. {
  10.   ....
  11.   char *currentstr = dictionary[0];
  12.   qsort(dictionary, sizeof dictionary / sizeof dictionary[0],
  13.         sizeof dictionary[0], cmp);
  14.   ....
  15. }
  16.  
  17. This suspicious code was found in Scilab project by PVS-Studio static code analyzer.
  18. Warning message is:
  19. V514 Dividing sizeof a pointer 'sizeof dictionary' by another value. There is a probability of logical error presence. getcommonpart.c 76
  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