diff --git a/test/cfg/std.c b/test/cfg/std.c index 8c96ae5ae..6c0ec4f04 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -3459,6 +3459,16 @@ void nullPointer_strncat(char *d, char *s, size_t n) (void)strncat(d,s,n); } +void nullPointer_strncpy(char *d, const char *s, size_t n) +{ + // cppcheck-suppress nullPointer + (void)strncpy(NULL,s,n); + // cppcheck-suppress nullPointer + (void)strncpy(d,NULL,n); + // no warning is expected for + (void)strncpy(d,s,n); +} + // errno_t strcat_s(char *restrict dest, rsize_t destsz, const char *restrict src); // since C11 void uninitvar_strcat_s(char *Ct, size_t N, char *S) { diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 057629e56..636340acf 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -1293,6 +1293,16 @@ void nullPointer_strncat(char *d, char *s, size_t n) (void)std::strncat(d,s,n); } +void nullPointer_strncpy(char *d, const char *s, size_t n) +{ + // cppcheck-suppress nullPointer + (void)std::strncpy(NULL,s,n); + // cppcheck-suppress nullPointer + (void)std::strncpy(d,NULL,n); + // no warning is expected for + (void)std::strncpy(d,s,n); +} + void nullPointer_strncmp(const char *s1, const char *s2, size_t n) { // cppcheck-suppress nullPointer