Professional Documents
Culture Documents
: : 09.03.2011
N1.
, , , . Miranda IM , Visual Studio Warning Level 3 (/W3), . PVS-Studio 4.14. . . 20% Miranda IM,
Miranda IM
1.
1)
, .
0( 1@2 8 3
' (@ )( 5@ F @ 3
@ 0 2A () E 3
55 )2')( E 3 ) 11@ 33 3
#
7 !"
!
#
!% $
() 6 ! ! # !
55 9' A 22( 3
) 3
) @ 1) 9 99' 3
V512 A c
f he ' e c y' f
b ffe
ve f w
@9 ( 10A (@
@9 (
@(
0@'
0A
5 2 2
@ 99)
} TEXTRANGEW;
...
...
LPWSTR lpstrText;
CHARRANGE chrg;
e se
ef w
e c y
'ch '
! "
U c
U c
C
!
1@ '0
!
he ec
e 302
f s ze f
s he '&
ex' ex ess
bs
c s_
0( 1@2
'9
0@'
(5
108 28 E
'
y e
sc
1080
void ExtraImage_SetAllExtraIcons(HWND hwndList,HANDLE hContact) { ... char *(ImgIndex[64]); ... memset(&ImgIndex,0,sizeof(&ImgIndex)); ... }
I I S d
64T
. .
.
X W VU
Copy- s e
V568 It's odd th t the argume t of s zeof operator is the '& ImgIndex' expression. c ist_mw extraimage.c 295 :
c ba ` Y V
memset(&ImgIndex,0,sizeof(ImgIndex));
, .
memset(ImgIndex,0,sizeof(ImgIndex));
.
c ba
V568 It's odd that the argument of sizeof operator is the '& rowOptTA' expression. c ist_modern modern_rowtemplateopt.cpp 258
RQP
I d
H T
, :
,
fe
V568 It's odd that the argument of sizeof operator is the '& rowOptTA' expression. clist_modern modern_rowtemplateopt.cpp 308 V568 It's odd that the argument of sizeof operator is the '& rowOptTA' expression. clist_modern modern_rowtemplateopt.cpp 438
fe
, , memset.
V512 A call of the 'memset' function will lead to a buffer overflow or underflow. clist_modern modern_image_array.cpp 59
static BOOL ImageArray_Alloc(LP_IMAGE_ARRAY_DATA iad, int size) { ... memset(&iad->nodes[iad->nodes_allocated_size], (size_grow - iad->nodes_allocated_size) * sizeof(IMAGE_ARRAY_DATA_NODE), 0); ... }
. . , 0 . :
, ,
, .
, O ENFILENA E:
OPENFILENAME x; memset(&x, 0, sizeof(x));
h g
memset
.
OPENFILENAME x = { 0 };
V547 Expression 'w aram >= 0' is always true. Unsigned type value is always >= 0. clist_mw cluiframes.c 3140
x
id2pos, . :
typedef UINT_PTR WPARAM; static int id2pos(int id); static int nFramescount=0;
'-1' id2pos
p q t
vu
i u r w
v s
qu
ui
s t
vu
q pi r
2.
i s r ww
, 'w aram>=0'
y
. . :
. Miranda IM . signed/unsigned . , .
33
V547 Expression 'nOldLength < 0' is always false. Unsigned type value is never < 0. IRC mstring.h 229
void Append( PCXSTR pszSrc, int nLength ) { ... UINT nOldLength = GetLength(); if (nOldLength < 0) { // protects from underflow nOldLength = 0;
} ... }
, ,
. .
WinA I).
#define SRMSGSET_LIMITNAMESLEN_MIN 0 static INT_PTR CALLBACK DlgProcTabsOptions(...) { ... limitLength = GetDlgItemInt(hwndDlg, IDC_LIMITNAMESLEN, NULL, TRUE) >= SRMSGSET_LIMITNAMESLEN_MIN ? GetDlgItemInt(hwndDlg, IDC_LIMITNAMESLEN, NULL, TRUE) : SRMSGSET_LIMITNAMESLEN_MIN; ... }
WINUSERAPI UINT WINAPI GetDlgItemInt( __in HWND hDlg, __in int nIDDlgItem, __out_opt BOOL *lpTranslated, __in BOOL bSigned);
PVS-Studio
V547 Expression is always true. Unsigned type value is always >= 0. scriver msgoptions.c 458 . SRMSGSET_LIMITNAMESLEN_MIN" , , , . "GetDlgItemInt(hwndDlg, IDC_LIMITNAMESLEN, NULL, TRUE) >= . , , . .
, . , . , . , : . , , , ,
V567 Undefined behavior. The 's' variable is modified while being used twice between sequence points. msn ezxml.c 371
short ezxml_internal_dtd(ezxml_root_t root, char *s, size_t len) { ... while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') { ... }
'strspn(s, EZXML_WS)'.
, 's'.
3.
, ,
. .
, .
LRESULT CLUI::OnDrawItem( UINT msg, WPARAM wParam, LPARAM lParam ) { ... DrawState(dis->hDC,NULL,NULL ,(LPARAM)hIcon,0, dis->rcItem.right+dis ->rcItem.leftGetSystemMetrics(SM_CXSMICON))/2+dx, (dis->rcItem.bottom+dis ->rcItem.topGetSystemMetrics(SM_CYSMICON))/2+dx, 0,0, DST_ICON| (dis->itemState&ODS_INACTIVE&&FALSE?DSS_DISABLED :DSS_NORMAL)); ... }
, ? .
UINT uFlags = DST_ICON; uFlags |= dis->itemState & ODS_INACTIVE && FALSE ? DSS_DISABLED : DSS_NORMAL;
FALSE. . ? . : ,
,
UINT uFlags;
if (dis->itemState & ODS_INACTIVE && (((FALSE)))) uFlags = DST_ICON | DSS_DISABLED; else uFlags = DST_ICON | DSS_NORMAL;
FALSE
, .
V537 Consider reviewing the correctness of 'maxX' item's usage. clist_modern modern_skinengine.cpp 2898
static BOOL ske_DrawTextEffect(...) { ... minX=max(0,minX+mcLeftStart -2); minY=max(0,minY+mcTopStart -2); maxX=min((int)width,maxX+mcRightEnd -1); maxY=min((int)height,maxX+mcBottomEnd -1); ... }
,
minX = max(0, minY = max(0, maxX = min((int)width, minX + mcLeftStart - 2); minY + mcTopStart maxX + mcRightEnd - 2); - 1);
, maxX.
, . Miranda IM. ,
V536 Be advised that the utilized constant value is represented by an octal form. Oct: 037, Dec: 31. msn msn_mime.cpp 192
f e
4.
Copy-Paste. .
} cptbl[] = { { { { { ... } 037, "IBM037" }, 437, "IBM437" }, 500, "IBM500" }, 708, "ASMO-708" }, // IBM EBCDIC US -Canada // OEM United States // IBM EBCDIC International // Arabic (ASMO 708)
, . . . , .
'0',
. . , . . . .
V525 The code containing the collection of similar blocks. Check items '1316', '1319', '1318', '1323', '1323', '1317', '1321' in lines 954, 955, 956, 957, 958, 959, 960. clist_modern modern_clcopts.cpp 954
static INT_PTR CALLBACK DlgProcTrayOpts(...) { ... EnableWindow(GetDlgItem(hwndDlg,IDC_PRIMARYSTATUS),TRUE); EnableWindow(GetDlgItem( hwndDlg,IDC_CYCLETIMESPIN),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIME),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSPRIMARY),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSPRIMARY),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_ CYCLE),FALSE); EnableWindow(GetDlgItem(hwndDlg,IDC_MULTITRAY),FALSE); ... }
ih
kq
l jg
gg
l o
lk j
ih
5.
, IDC_ALWAYSPRIMARY. .
. ,
, . . , . , , , . , : , . . , , . . , ,
V560 A part of conditional expression is always true: 0x01000. tabsrmm tools.cpp 1023
DWORD dwFlags;
UINT CreateGCMenu(...) { ... if (iIndex == 1 && si ->iType != GCW_SERVER && !(si->dwFlags && GC_UNICODE)) { ... }
. ,
'&' . :
'&&'.
y ut
|x
vy{ w
w x
y { wy r} t r r
{ wsx
vy
x y ~
s w r
s ut r v z} x t
6.
y
. V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant: *str != '\0'. clist_modern modern_skinbutton.cpp 282 V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant: *endstr != '\0'. clist_modern modern_skinbutton.cpp 283
static char *_skipblank(char * str) { char * endstr=str+strlen(str); while ((*str==' ' || *str==' \t') && str!='\0') str++; while ((*endstr==' ' || *endstr =='\t') && endstr!='\0' && endstr<str) endstr--; ... }
. :
while ((*str==' ' || *str=='\t') && *str!='\0') str++; while ((*endstr==' ' || *endstr==' \t') && *endstr!='\0' && endstr<str) endstr--;
, .
. V514 Dividing sizeof a pointer 'sizeof (text)' by another value. There is a probability of logical error presence. clist_modern modern_cachefuncs.cpp 567
int Cache_GetLineText(..., LPTSTR text, int text_size, ...) { ... tmi.printDateTime(pdnce ->hTimeZone, _T("t"), text, SIZEOF(text), 0); ... }
, . , "sizeof(LPTSTR) /
V560 A part of conditional expression is always true: 0x29. icqoscar8 fam_03buddy.cpp 632
void CIcqProto::handleUserOffline(BYTE *buf, WORD wLen) { ... else if (wTLVType = 0x29 && wTLVLen == sizeof(DWORD)) ... }
. :
if (0x29 = wTLVType && sizeof(DWORD) == wTLVLen)
, , . ,
. ,
, , Miranda IM , : V542 Consider inspecting an odd type cast: 'char *' to 'char'. clist_modern modern_toolbar.cpp 586 . . ,
static void sttRegisterToolBarButton(..., char * pszButtonName, ...) { ... if ((BYTE)pszButtonName) tbb.tbbFlags=TBBF_FLEXSIZESEPARATOR; else tbb.tbbFlags=TBBF_ISSEPARATOR; ... }
, .
256. ,
, .
V501 There are identical sub-expressions 'user->statusMessage' to the left and to the right of the '&&' operator. jabber jabber_chat.cpp 214
void CJabberProto::GcLogShowInformation(...)
. , .
, . , . , , . . . ';' , 10 'for'. . , , , .
, ++. . ,
P.S.
, / Miranda IM. , , , Miranda IM , , : V523 The 'then' statement is equivalent to the 'else' statement. scriver msglog.c 695
if ( streamData->isFirst ) {
, ,
. . . ,
. , PVS-Studio. , . . , ,
if (event->dwFlags & IEEDF_RTL) { AppendToBuffer(&buffer, & bufferEnd, &bufferAlloced, " \\rtlpar"); } else { AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " \\ltrpar"); } } else { if (event->dwFlags & IEEDF_RTL) { AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " \\rtlpar"); } else { AppendToBuffer(&buffer, &bufferEnd, &bufferAlloced, " \\ltrpar"); } }
. . . .
, ,
. ,