From c17d3a10220cf4afbf751712e88895e2989d0b46 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Wed, 20 Apr 2022 17:52:38 +0200 Subject: [PATCH] posix.cfg: Ensure null pointer input is correctly handled for stpcpy(). --- test/cfg/posix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/cfg/posix.c b/test/cfg/posix.c index a94aaa8d3..ef1ecb546 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -216,6 +216,16 @@ char * overlappingWriteFunction_stpcpy(char *src, char *dest) return stpcpy(src, src); } +char * nullPointer_stpcpy(char *src, char *dest) +{ + // No warning shall be shown: + (void) stpcpy(dest, src); + // cppcheck-suppress nullPointer + (void) stpcpy(dest, NULL); + // cppcheck-suppress nullPointer + return stpcpy(NULL, src); +} + void overlappingWriteFunction_bcopy(char *buf, const size_t count) { // No warning shall be shown: