test/cfg/std.c: Add nullPointer tests for vsnprintf() (#2262)

Related tickets:
https://trac.cppcheck.net/ticket/9408
https://trac.cppcheck.net/ticket/9410
This commit is contained in:
Sebastian 2019-10-11 20:00:10 +02:00 committed by GitHub
parent 530d4d2427
commit e24008544e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -347,6 +347,26 @@ void nullPointer_wmemcmp(wchar_t *p)
(void)wmemcmp(p, 0, 123);
}
void nullPointer_vsnprintf(const char * format, ...)
{
va_list args;
// valid
char buffer[256];
va_start(args, format);
vsnprintf(buffer, 256, format, args);
printf("%s", buffer);
va_end(args);
// valid
va_start(args, format);
vsnprintf(NULL, 0, format, args);
va_end(args);
// invalid
va_start(args, format);
// TODO #9410 cppcheck-suppress nullPointer
vsnprintf(NULL, 10, format, args);
va_end(args);
}
// uninit pointers
void uninitvar_abs(void)