You are on page 1of 3

PVS-Studio is a static analyzer detecting errors in source code of C/C++/C++0x software.

There are 3 rule sets included into PVS-Studio:


1. Diagnostic of 64-bit errors (Viva64) 2. Diagnostic of parallel errors (VivaMP) 3. General diagnostic

marking of the program text to check only new code.

auto_ptr<VARIANT> child_array(new VARIANT[child_count]); You cannot use auto_ptr for arrays. Only one item is destroyed in the auto_ptr destructor: ~auto_ptr() { delete _Myptr; } WinDjView is a fast and compact application to view DjVu files. V560 A part of conditional expression is always true: 0xA. xmlparser.cpp 45 inline bool IsValidChar(int c) { return c == 0x9 || 0xA || c == 0xD || c >= 0x20 && c <= 0xD7FF || c >= 0xE000 && c <= 0xFFFD || c >= 0x10000 && c <= 0x10FFFF; } The programmer has misprinted here and written "0xA" instead of "c == 0xA". FCE Ultra is an opensource emulator of the Nintendo Entertainment System video-games attachment. V561 It's probably better to assign value to 'x' variable than to declare it anew. Previous declaration: ines.cpp, line 960. ines.cpp 962 fp = fopen(name,"wb"); int x = 0; if (!fp) int x = 1; The 'x' variable was defined twice as a result, the emulator always supposes that it has managed to open a file.

The PVS-Studio tool is intended for developers of contemporary software and integrates into the Visual Studio 2005/2008/2010 environment providing a convenient user interface for file analysis, code navigation and Help access.

Enough of verbiage! Say no to advertising texts! Examples will tell you much better of PVS-Studios capabilities. Below are issues our code analyzer has detected in some applications. Return to Castle Wolfenstein is a computer game, 1st person shooter developed by the id Software company. V564 The '&' operator is applied to bool type value. You've probably forgotten to include parentheses or intended to use the '&&' operator. g_client.c 1534 #define SVF_CASTAI 0x00000010 if ( !ent->r.svFlags & SVF_CASTAI ) Parentheses are missing. It is the "!ent->r.svFlags" subexpression which is calculated first and only then the '&' operation is executed. Miranda IM instant messenger. V567 Undefined behavior. The 's' variable is modified while being used twice between sequence points. ezxml.c 371 while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') { There is no guarantee that 's' will be incremented before calling the strspn() function. Chromium is an opensource web-browser developed by the Google company. Chromium serves as the basis for the Google Chrome browser being developed currently. V554 Incorrect use of auto_ptr. The memory allocated with 'new []' will be cleaned using 'delete'. accessibility_win_browsertest.cc 171

To handle the analyzer, you do not need to spend your time on reading documentations and setting the tool before using it. The analyzer is ready to work right after being installed. PVS-Studios features

integration with Visual Studio 2005/2008/2010; support of continuous integration systems; online-help in Russian and English; .pdf documentation; saving and loading of analysis results; multi-core and multi-processor support; the leader in the sphere of 64-bit issue diagnostic; estimate of complexity of code migration to 64 bits; interactive filters; convenient integration into the team development process;

TortoiseSVN is a Subversion client, implemented as a Microsoft Windows shell extension. V547 Expression '* utf8CheckBuf == 0xC0' is always false. The value range of signed char type: [-128, 127]. tortoiseblame.cpp 310

(and two more V547 warnings) // check each line for illegal utf8 sequences. char * utf8CheckBuf = lineptr; while ((bUTF8)&&(*utf8CheckBuf)) { if ((*utf8CheckBuf == 0xC0)|| (*utf8CheckBuf == 0xC1)|| (*utf8CheckBuf >= 0xF5)) { The intended condition is not checked. The expression is always false. WinMerge is an opensource software to compare and synchronize files and directories. V530 The return value of function 'empty' is required to be utilized. DirActions.cpp 1307, 1308 if (diffpos == (UINT_PTR)SPECIAL_ITEM_POS) { strLeft.empty(); strRight.empty(); } The code fragment must empty the strings at certain condition. But the programmer has written std::string::empty() by accident instead of std::string::clear(). Notepad++ is a free text editor with syntax highlight.

objects.

Mailbox: Post office box 1800, Tula, 300027 Our offices address: Office 73 (7th story) 100 Kutuzova St., Tula Working hours: 9.00 18.00 Moscow time.

V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a lower priority than the '*' operator. dgminkowskiconv.cpp 1061 den = dgFloat32 (1.0e-24f) * (den > dgFloat32(0.0f)) ? dgFloat32(1.0f) : dgFloat32(-1.0f); The '?:' operators priority is lower than that of the multiplication operator '*'. Fennec Media Project universal media-player.

V540 Member 'lpstrFilter' should point to string terminated by two 0 characters. windows.c 5309 OPENFILENAME lofn; ... lofn.lpstrFilter = uni("All Files (*.*)\0*.*"); The programmer has forgotten to add two zeroes at the end. Even unit-tests will not help here only manual testing. This is the correct code: lofn.lpstrFilter = uni("All Files (*.*)\0*.*\0");

V512: A call of the memset function will lead to a buffer overflow or underflow. DockingManager.cpp 60 #define CONT_MAP_MAX 50 int _iContMap[CONT_MAP_MAX]; ... memset(_iContMap, -1, CONT_MAP_MAX); Only a part of the array is filled since there is a missing operation of "CONT_MAP_MAX" and "sizeof(int)" multiplication. Newton Game Dynamics is a popular physical engine for simulation of physical behavior of background

You may see a detailed description of the PVS-Studio tool on the site: http://www.viva64.com/en/pvs-studio/ You may also download the demo version: http://www.viva64.com/en/pvs-studio-download/

PVS-Studio searching for errors in C / C++ / C++0x code

Contacts OOO Program Verification Systems Site: www.viva64.com e-mail: support@viva64.com Legal address: 70-1-88 Metallurgov St., Tula, 300027

OOO "Program Verification Systems"

www.viva64.com

You might also like