:
: 09.03.2011
Miranda IM.
, 950
C C++. , ,
.
, .
, Miranda IM,
,
.
Miranda IM PVS-Studio 4.14. Miranda IM
, .
.
Visual Studio Warning Level 3 (/W3), 20%
.
,
, memset, memcpy, ZeroMemory .
. ,
. ,
,
. ,
:
1) . ,
.
2) .
.
. ,
, Miranda.
. , memset/memcpy
. , ,
,
. , Miranda IM.
V512 A call of the 'memcpy' function will lead to a buffer overflow or underflow. tabsrmm utils.cpp 1080
typedef struct _textrangew
{
CHARRANGE chrg;
LPWSTR lpstrText;
} TEXTRANGEW;
.
V568 It's odd that the argument of sizeof() operator is the '& rowOptTA' expression. clist_modern
modern_rowtemplateopt.cpp 258
, , .
"sizeof(rowOptTA)".
:
const size_t ArraySize = 100;
static ROWCELL* rowOptTA[ArraySize];
...
std::fill(rowOptTA, rowOptTA + ArraySize, nullptr);
, :
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
, ? , .
, 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 . :
memset(&iad->nodes[iad->nodes_allocated_size], 0,
(size_grow - iad->nodes_allocated_size) *
sizeof(IMAGE_ARRAY_DATA_NODE));
, . ,
, .
, memset ,
OPENFILENAME:
OPENFILENAME x;
memset(&x, 0, sizeof(x));
. :
OPENFILENAME x = { 0 };
2. ,
signed unsigned
. .
, ,
, int unsigned.
, .
. ,
, ,
.
,
. , , ,
. .
V547 Expression 'wParam >= 0' is always true. Unsigned type value is always >= 0. clist_mw
cluiframes.c 3140
id2pos, '-1' .
. id2pos
:
typedef UINT_PTR WPARAM;
static int id2pos(int id);
static int nFramescount=0;
{
...
wParam=id2pos(wParam);
if(wParam>=0&&(int)wParam<nFramescount)
if (Frames[wParam].floating)
...
}
, wParam . ,
'wParam>=0' . id2pos '-1',
, .
, :
if (wParam>=0 && wParam<nFramescount)
Visual C++ "warning C4018: '<' : signed/unsigned mismatch".
Warning Level 3, Miranda IM.
.
. , .
:
if ((INT_PTR)wParam>=0 && (INT_PTR)wParam<nFramescount)
. Miranda IM 33 ,
- signed/unsigned .
. . , .
V547 Expression 'nOldLength < 0' is always false. Unsigned type value is never < 0. IRC mstring.h 229
}
...
}
, .
, .
( WinAPI).
#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;
...
}
, . ,
. . ,
.
, GetDlgItemInt() 'int', .
UINT. "WinUser.h":
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
. "GetDlgItemInt(hwndDlg, IDC_LIMITNAMESLEN, NULL, TRUE) >=
SRMSGSET_LIMITNAMESLEN_MIN" .
, , .
, , . , .
3.
,
. , ,
,
.
, , ,
.
, .
:
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 != '>') {
...
}
(undefined behavior).
. ,
.
'++s', 'strspn(s, EZXML_WS)'. , ,
, 's'.
, . Miranda IM
/ '&& 0'.
:
if ((1 || altDraw) && ...
if (g_CluiData.bCurrentAlpha==GoalAlpha &&0)
if(checkboxWidth && (subindex==-1 ||1)) {
. ,
. . .
V560 A part of conditional expression is always false: 0. clist_modern modern_clui.cpp 2979
, , , :
UINT uFlags;
if (dis->itemState & ODS_INACTIVE && (((FALSE))))
uFlags = DST_ICON | DSS_DISABLED;
else
uFlags = DST_ICON | DSS_NORMAL;
, , , FALSE .
4. ,
Copy-Paste.
, .
.
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,
minY + mcTopStart
- 2);
maxX = min((int)width,
maxX + mcRightEnd
- 1);
} cptbl[] =
{
{
037, "IBM037" },
437, "IBM437" },
500, "IBM500" },
708, "ASMO-708" },
...
}
, '0',
.
. , . ,
.
5. ,
. ,
.
, . . .
- . :
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
, .
IDC_ALWAYSPRIMARY. ,
.
6.
,
. , ,
.
, .
- . -
.
- , .
, . ,
, , ,
.
,
:
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)) {
...
}
. '&' '&&'.
, . :
.
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
'*' .
. access violation. :
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
. ,
SIZEOF. COUNT_OF, . ,
. "sizeof(LPTSTR) /
sizeof(TCHAR)". ,
. :
tmi.printDateTime(pdnce->hTimeZone, _T("t"), text, text_size, 0);
V560 A part of conditional expression is always true: 0x29. icqoscar8 fam_03buddy.cpp 632
.
:
if (0x29 = wTLVType && sizeof(DWORD) == wTLVLen)
, , . ,
, , ,
.
,
/, .
, , , .
Miranda IM, PVS-Studio V559:
else if (ft->ft_magic = FT_MAGIC_OSCAR)
if (ret=0) {return (0);}
if (Drawing->type=CLCIT_CONTACT)
, .
, 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(...)
{
...
if (user->statusMessage && user->statusMessage)
...
}
. , .
,
.
,
. . ,
, , .
,
.
-. ,
. ,
';' 'for'.
, 10 .
,
++. ,
.
P.S.
, , - ,
/ . ,
Miranda IM.
, . .
, . , , ,
, . ,
Miranda IM PVS-Studio.
, , .
, .
:
V523 The 'then' statement is equivalent to the 'else' statement. scriver msglog.c 695
if ( streamData->isFirst ) {