Skip to content

Commit 1055b11

Browse files
committed
posix.cfg: Ensure null pointer input is correctly handled for gethostname().
1 parent d0ff2a0 commit 1055b11

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/cfg/posix.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ int nullPointer_wcsnlen(const wchar_t *s, size_t n)
4848
return wcsnlen(s, n);
4949
}
5050

51+
int nullPointer_gethostname(char *s, size_t n)
52+
{
53+
// cppcheck-suppress nullPointer
54+
(void)gethostname(NULL, n);
55+
// No warning is expected
56+
return gethostname(s, n);
57+
}
58+
5159
int nullPointer_wcswidth(const wchar_t *s, size_t n)
5260
{
5361
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)