std.cfg: Improved tests for memchr().

This commit is contained in:
orbitcowboy 2022-05-01 18:09:54 +02:00
parent e9a0d7979e
commit 6f6ddb99b2
2 changed files with 18 additions and 0 deletions

View File

@ -2697,6 +2697,15 @@ void uninitvar_memchr(void)
(void)memchr(cs,c,n);
}
void *bufferAccessOutOfBounds_memchr(const void *s, int c, size_t n)
{
char buf[42]={0};
(void)memchr(buf,c,42);
// cppcheck-suppress bufferAccessOutOfBounds
(void)memchr(buf,c,43);
return memchr(s,c,n);
}
void uninitvar_wmemchr(void)
{
wchar_t *cs;

View File

@ -32,6 +32,15 @@
#include <iterator>
#include <vector>
void *bufferAccessOutOfBounds_memchr(void *s, int c, size_t n)
{
char buf[42]={0};
(void)std::memchr(buf,c,42);
// cppcheck-suppress bufferAccessOutOfBounds
(void)std::memchr(buf,c,43);
return std::memchr(s,c,n);
}
// As with all bounds-checked functions, localtime_s is only guaranteed to be available if __STDC_LIB_EXT1__ is defined by the implementation and if the user defines __STDC_WANT_LIB_EXT1__ to the integer constant 1 before including time.h.
#ifdef __STDC_LIB_EXT1__
void uninitvar_localtime_s(const std::time_t *restrict time, struct tm *restrict result)