diff --git a/cfg/std.cfg b/cfg/std.cfg index 164371ca7..c0c5dbbe3 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -2312,6 +2312,7 @@ + diff --git a/test/cfg/std.c b/test/cfg/std.c index 26f02bba8..3dce3c204 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -1598,6 +1598,15 @@ void uninitvar_mbrlen(const char* p, size_t m, mbstate_t* s) (void)mbrlen(p,m,s); } +void nullPointer_mbrlen(const char* p, size_t m, mbstate_t* s) +{ + /* no warning is expected: A call to the function with a null pointer as pmb resets the shift state (and ignores parameter max). */ + (void)mbrlen(NULL,m,s); + (void)mbrlen(NULL,0,s); + /* cppcheck-suppress nullPointer */ + (void)mbrlen(p,m,NULL); +} + void uninitvar_btowc(void) { int c; diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index a61e8e7c7..d9cd7b261 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -1106,6 +1106,15 @@ void uninitvar_mbrlen(const char* p, size_t m, mbstate_t* s) (void)std::mbrlen(p,m,s); } +void nullPointer_mbrlen(const char* p, size_t m, mbstate_t* s) +{ + // no warning is expected: A call to the function with a null pointer as pmb resets the shift state (and ignores parameter max). + (void)std::mbrlen(NULL,m,s); + (void)std::mbrlen(NULL,0,s); + // cppcheck-suppress nullPointer + (void)std::mbrlen(p,m,NULL); +} + void uninitvar_btowc(void) { int c;