Skip to content

Commit 7c766a9

Browse files
committed
gnu.cfg: Ensure a nullPointer warning is shown for invalid input to mempcpy() and wmempcpy().
1 parent ce369c5 commit 7c766a9

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/cfg/gnu.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,29 @@
1616
#include <sys/types.h>
1717
#include <pwd.h>
1818
#include <sys/mman.h>
19+
#include <wchar.h>
1920
#ifndef __CYGWIN__
2021
#include <sys/epoll.h>
2122
#endif
2223

24+
void *nullPointer_mempcpy(void *dest, const void *src, size_t n)
25+
{
26+
// cppcheck-suppress nullPointer
27+
(void) mempcpy(NULL,src,n);
28+
// cppcheck-suppress nullPointer
29+
(void) mempcpy(dest,NULL,n);
30+
return mempcpy(dest,src,n);
31+
}
32+
33+
wchar_t *nullPointer_wmempcpy(wchar_t *dest, const wchar_t *src, size_t n)
34+
{
35+
// cppcheck-suppress nullPointer
36+
(void) wmempcpy(NULL,src,n);
37+
// cppcheck-suppress nullPointer
38+
(void) wmempcpy(dest,NULL,n);
39+
return wmempcpy(dest,src,n);
40+
}
41+
2342
int uninitvar_getpw(uid_t uid, char *buf)
2443
{
2544
uid_t someUid;

0 commit comments

Comments
 (0)