test/cfg: Improved testing of std.cfg regarding null pointer dereferences.

This commit is contained in:
orbitcowboy 2015-09-11 16:29:39 +02:00
parent 7dadd9f3ca
commit 3187a2b972
3 changed files with 118 additions and 1 deletions

View File

@ -288,7 +288,7 @@
</arg>
</function>
<!-- int fegetenv(fenv_t* envp); -->
<function name="fegetenv">
<function name="fegetenv,std::fegetenv">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">

View File

@ -3386,3 +3386,62 @@ void ignoredReturnValue_abs(int i)
// cppcheck-suppress constStatement
abs(-100);
}
void nullPointer_asctime(void)
{
struct tm *tm = 0;
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress nullPointer
(void)asctime(tm);
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress nullPointer
(void)asctime(0);
}
void nullPointer_wcsftime(size_t maxsize)
{
wchar_t* ptr = 0;
wchar_t* format = 0;
struct tm* timeptr = 0;
// cppcheck-suppress nullPointer
(void)wcsftime(ptr,maxsize,format,timeptr);
// cppcheck-suppress nullPointer
(void)wcsftime(0,maxsize,0,0);
}
void nullPointer_fegetenv(void)
{
fenv_t* envp = 0;
// cppcheck-suppress nullPointer
(void)fegetenv(envp);
// cppcheck-suppress nullPointer
(void)fegetenv(0);
}
void nullPointer_fegetexceptflag(int excepts)
{
fexcept_t* flagp = 0;
// cppcheck-suppress nullPointer
(void)fegetexceptflag(flagp,excepts);
// cppcheck-suppress nullPointer
(void)fegetexceptflag(0,excepts);
}
void nullPointer_feholdexcept(void)
{
fenv_t* envp = 0;
// cppcheck-suppress nullPointer
(void)feholdexcept(envp);
// cppcheck-suppress nullPointer
(void)feholdexcept(0);
}
void nullPointer_fesetenv(void)
{
fenv_t* envp = 0;
// cppcheck-suppress nullPointer
(void)fesetenv(envp);
// cppcheck-suppress nullPointer
(void)fesetenv(0);
}

View File

@ -2741,3 +2741,61 @@ void ignoredReturnValue_abs(int i)
// cppcheck-suppress constStatement
std::abs(-199);
}
void nullPointer_asctime(void)
{
struct tm *tm = 0;
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress nullPointer
(void)std::asctime(tm);
// cppcheck-suppress obsoleteFunctionsasctime
// cppcheck-suppress nullPointer
(void)std::asctime(0);
}
void nullPointer_wcsftime(size_t maxsize)
{
wchar_t* ptr = 0;
wchar_t* format = 0;
struct tm* timeptr = 0;
// cppcheck-suppress nullPointer
(void)std::wcsftime(ptr,maxsize,format,timeptr);
// cppcheck-suppress nullPointer
(void)std::wcsftime(0,maxsize,0,0);
}
void nullPointer_fegetenv(void)
{
fenv_t* envp = 0;
// cppcheck-suppress nullPointer
(void)std::fegetenv(envp);
// cppcheck-suppress nullPointer
(void)std::fegetenv(0);
}
void nullPointer_fegetexceptflag(int excepts)
{
fexcept_t* flagp = 0;
// cppcheck-suppress nullPointer
(void)std::fegetexceptflag(flagp,excepts);
// cppcheck-suppress nullPointer
(void)std::fegetexceptflag(0,excepts);
}
void nullPointer_feholdexcept(void)
{
fenv_t* envp = 0;
// cppcheck-suppress nullPointer
(void)std::feholdexcept(envp);
// cppcheck-suppress nullPointer
(void)std::feholdexcept(0);
}
void nullPointer_fesetenv(void)
{
fenv_t* envp = 0;
// cppcheck-suppress nullPointer
(void)std::fesetenv(envp);
// cppcheck-suppress nullPointer
(void)std::fesetenv(0);
}