diff --git a/cfg/std.cfg b/cfg/std.cfg index 82facb1f4..ad3e12ead 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4546,6 +4546,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + 0:255 diff --git a/test/cfg/std.c b/test/cfg/std.c index faecabce7..fcb3e4f31 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -2901,6 +2901,19 @@ void uninitvar_strchr(void) (void)strchr(cs,c); } +void invalidFunctionArg_strchr(char *cs, int c) +{ + // cppcheck-suppress invalidFunctionArg + (void)strchr(cs,-1); + + // No warning shall be issued for + (void)strchr(cs, 0); + (void)strchr(cs, 255); + + // cppcheck-suppress invalidFunctionArg + (void)strchr(cs, 256); +} + void uninitvar_wcschr(void) { wchar_t *cs;