Hi, On Tue, Oct 05, 2021 at 05:32:16PM +0200, Jan-Benedict Glaw wrote: > I'm running automated test compiles on Binutils, GCC, Linux, NetBSD > and, since a few days ago, elfutils. > > Building/running the tests, I noticed this little warning: > > [make 2021-10-01 12:18:15] elflint.c: In function 'check_sections': > [make 2021-10-01 12:18:15] elflint.c:4105:48: error: null pointer dereference [-Werror=null-dereference] > [make 2021-10-01 12:18:15] 4105 | idx < databits->d_size && ! bad; > [make 2021-10-01 12:18:15] | ~~~~~~~~^~~~~~~~ > [make 2021-10-01 12:18:18] cc1: all warnings being treated as errors > [make 2021-10-01 12:18:18] make[2]: *** [Makefile:799: elflint.o] Error 1 > [make 2021-10-01 12:18:18] make[1]: *** [Makefile:532: all-recursive] Error 1 > [make 2021-10-01 12:18:18] make: *** [Makefile:448: all] Error 2 > > > As it is tested beforehand that we should not run into this, this > patch should fix the warning: > > > diff --git a/src/elflint.c b/src/elflint.c > index 1ce75684..ef7725ce 100644 > --- a/src/elflint.c > +++ b/src/elflint.c > @@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but is read from the file in segment of prog > bad = (databits == NULL > || databits->d_size != shdr->sh_size); > for (size_t idx = 0; > - idx < databits->d_size && ! bad; > + ! bad && idx < databits->d_size; > idx++) > bad = ((char *) databits->d_buf)[idx] != 0; > Thanks, that warning and the fix look correct. I committed the attached fix. Cheers, Mark