From e0942c1bb4d791848921144b23c0cbe22bf4ee7c Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Tue, 19 Apr 2022 21:21:35 +0200 Subject: [PATCH] std.cfg: Ensure warnings are issued for passing null pointer to bsearch(). --- test/cfg/std.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/cfg/std.c b/test/cfg/std.c index afb1e1947..75aad265f 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -2854,6 +2854,16 @@ void uninitvar_vwprintf(wchar_t *Format, va_list Arg) (void)vwprintf(Format,arg); } +void nullPointer_bsearch(void* key, void* base, size_t num, size_t size) +{ + // cppcheck-suppress nullPointer + (void)bsearch(NULL,base,num,size,(int (*)(const void*,const void*))strcmp); + // cppcheck-suppress nullPointer + (void)bsearch(key,NULL,num,size,(int (*)(const void*,const void*))strcmp); + // No warning is expected + (void)bsearch(key,base,num,size,(int (*)(const void*,const void*))strcmp); +} + void uninitvar_bsearch(void) { void* key;