Skip to content

Commit ce35a6c

Browse files
committed
std.cfg: Added more tests for strcat() and strcpy().
1 parent e683f3c commit ce35a6c

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

test/cfg/std.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,6 +3113,28 @@ void uninitvar_strcat(char *dest, const char * const source)
31133113
(void)strcat(dest,source);
31143114
}
31153115

3116+
void nullPointer_strcpy(char *dest, const char * const source)
3117+
{
3118+
// cppcheck-suppress nullPointer
3119+
(void)strcpy(NULL,source);
3120+
// cppcheck-suppress nullPointer
3121+
(void)strcpy(dest,NULL);
3122+
3123+
// no warning shall be shown for
3124+
(void)strcpy(dest,source);
3125+
}
3126+
3127+
void nullPointer_strcat(char *dest, const char * const source)
3128+
{
3129+
// cppcheck-suppress nullPointer
3130+
(void)strcat(NULL,source);
3131+
// cppcheck-suppress nullPointer
3132+
(void)strcat(dest,NULL);
3133+
3134+
// no warning shall be shown for
3135+
(void)strcat(dest,source);
3136+
}
3137+
31163138
void bufferAccessOutOfBounds_strcat(char *dest, const char * const source)
31173139
{
31183140
char buf4[4] = {0};

test/cfg/std.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,28 @@ void nullPointer_strncat(char *d, char *s, size_t n)
12931293
(void)std::strncat(d,s,n);
12941294
}
12951295

1296+
void nullPointer_strcpy(char *dest, const char * const source)
1297+
{
1298+
// cppcheck-suppress nullPointer
1299+
(void)std::strcpy(NULL,source);
1300+
// cppcheck-suppress nullPointer
1301+
(void)std::strcpy(dest,NULL);
1302+
1303+
// no warning shall be shown for
1304+
(void)std::strcpy(dest,source);
1305+
}
1306+
1307+
void nullPointer_strcat(char *dest, const char * const source)
1308+
{
1309+
// cppcheck-suppress nullPointer
1310+
(void)std::strcat(NULL,source);
1311+
// cppcheck-suppress nullPointer
1312+
(void)std::strcat(dest,NULL);
1313+
1314+
// no warning shall be shown for
1315+
(void)std::strcat(dest,source);
1316+
}
1317+
12961318
void nullPointer_strncpy(char *d, const char *s, size_t n)
12971319
{
12981320
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)