Примеры ошибок, обнаруженных с помощью диагностики V527
V527. The 'zero' value is assigned to pointer. Probably meant: *ptr = zero.
PNG library
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *new_key [79] = '\0'. graphics3D pngwutil.c 1283
png_size_t /* PRIVATE */
png_check_keyword(png_structp png_ptr, png_charp key,
png_charpp new_key)
{
....
if (key_len > 79)
{
png_warning(png_ptr,
"keyword length must be 1 - 79 characters");
new_key[79] = '\0';
key_len = 79;
}
....
}
This is what should have been written here: (*new_key)[79] = '\0';
Apache HTTP Server
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *tag->arg = '\0'. mod_headers mod_headers.c 330
typedef struct {
const char* (*func)(request_rec *r,char *arg);
char *arg;
} format_tag;
static char *parse_format_tag(apr_pool_t *p,
format_tag *tag,
const char **sa)
{
....
tag->arg = '\0';
....
}
This is what should have been written here: tag->arg = NULL; or tag->arg[0] = '\0';.
ReactOS
V527 It is odd that the L'\0' value is assigned to 'wchar_t' type pointer. Probably meant: *lpBackSlash = L'\0'. desk screensaver.c 453
static VOID
AddScreenSavers(HWND hwndDlg, PDATA pData)
{
....
LPTSTR lpBackSlash;
lpBackSlash = _tcsrchr(szSearchPath, _T('\\'));
if (lpBackSlash != NULL)
{
lpBackSlash = '\0';
SearchScreenSavers(hwndScreenSavers, szSearchPath, pData);
}
}
The programmer simply zeroed the IpBackSlash pointer instead of throwing off everything after the last \ character. This is what should have been written here: *lpBackSlash = '\0';
Trans-Proteomic Pipeline
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *pEndAttrValue = '\0'. tpplib ramp.cpp 1856
RAMPREAL *readPeaks(RAMPFILE *pFI,
ramp_fileoffset_t lScanIndex)
{
....
else
{
const char* pEndAttrValue;
pEndAttrValue =
strchr(pBeginData + strlen("contentType=\"") + 1, '\"');
pEndAttrValue = '\0';
fprintf(stderr, "%s Unsupported content type\n",
pBeginData);
return NULL;
}
....
}
This is what should have been written here: *pEndAttrValue = '\0';
Similar errors can be found in some other places:
- V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *pEndAttrValue = '\0'. tpplib ramp.cpp 1875
- V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *pEndAttrValue = '\0'. spectrast spectrast_ramp.cpp 1844
- V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *pEndAttrValue = '\0'. spectrast spectrast_ramp.cpp 1863
Scilab
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *last = '\0'. getenvb.c 24
void GetenvB(char *name, char *env, int len)
{
int ierr = 0, one = 1;
C2F(getenvc)(&ierr,name,env,&len,&one);
if (ierr == 0)
{
char *last = &env[len-1];
while ( *last == ' ' ) { last = '\0' ; }
last--;
}
....
}
Most likely this is what should be written here: while ( *last == ' ' ) { *last++ = '\0' ; }
Haiku Operation System
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *scratchPtr = '\0'. TextGapBuffer.cpp 228
const char*
TextGapBuffer::Text()
{
const char* realText = RealText();
if (fPasswordMode) {
....
char* scratchPtr = fScratchBuffer;
for (uint32 i = 0; i < numChars; i++) {
memcpy(scratchPtr, B_UTF8_BULLET, bulletCharLen);
scratchPtr += bulletCharLen;
}
scratchPtr = '\0'; // <=
return fScratchBuffer;
}
return realText;
}
Tizen
V527 It is odd that the '\0' value is assigned to 'char' type pointer. Probably meant: *body[new_len] = '\0'. http_request.c 370
int _read_request_body(...., char **body)
{
....
*body = realloc(*body, new_len + 1);
....
memcpy(*body + curr_len, ptr, body_size);
body[new_len] = '\0'; // <=
curr_len = new_len;
....
}
This is what should have been written here: (*body)[new_len] = '\0';