Skip to content

Commit e0942c1

Browse files
committed
std.cfg: Ensure warnings are issued for passing null pointer to bsearch().
1 parent b7bffaa commit e0942c1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

test/cfg/std.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,6 +2854,16 @@ void uninitvar_vwprintf(wchar_t *Format, va_list Arg)
28542854
(void)vwprintf(Format,arg);
28552855
}
28562856

2857+
void nullPointer_bsearch(void* key, void* base, size_t num, size_t size)
2858+
{
2859+
// cppcheck-suppress nullPointer
2860+
(void)bsearch(NULL,base,num,size,(int (*)(const void*,const void*))strcmp);
2861+
// cppcheck-suppress nullPointer
2862+
(void)bsearch(key,NULL,num,size,(int (*)(const void*,const void*))strcmp);
2863+
// No warning is expected
2864+
(void)bsearch(key,base,num,size,(int (*)(const void*,const void*))strcmp);
2865+
}
2866+
28572867
void uninitvar_bsearch(void)
28582868
{
28592869
void* key;

0 commit comments

Comments
 (0)