PVS-StudioWarnings

PVS-Studio warning V668 for Virtualdub

Nov 19th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. void HexEditor::Find(HWND hwndParent) {
  2.   ....
  3.   int *next = new int[nFindLength+1];
  4.   char *searchbuffer = new char[65536];
  5.   char *revstring = new char[nFindLength];
  6.   ....
  7.   if (!next || !searchbuffer || !revstring) {
  8.     delete[] next;
  9.     delete[] searchbuffer;
  10.     delete[] revstring;
  11.     return;
  12.   }
  13.   ....
  14. }
  15.  
  16. This suspicious code was found in Virtualdub project by PVS-Studio static code analyzer.
  17. Warning message is:
  18. V668 There is no sense in testing the 'next' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. VirtualDub hexviewer.cpp 2012
  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