Fix GCC6 -Wnull-dereference warnings.
authorMark Wielaard <mjw@redhat.com>
Fri, 12 Feb 2016 22:59:32 +0000 (23:59 +0100)
committerMark Wielaard <mjw@redhat.com>
Mon, 22 Feb 2016 11:09:25 +0000 (12:09 +0100)
commitc3aa57416566c97888abbc5c2ef4631c8c9e16f0
treee44d19e5664942eb7868e2e2412648d0c772bb50
parent2f289fa9e34c7cf67403907a354abe8ecaf380d2
Fix GCC6 -Wnull-dereference warnings.

asm_begin.c: In function ‘asm_begin’:
asm_begin.c:62:7: error: potential null pointer dereference [-Werror=null-dereference]
       __fsetlocking (result->out.file, FSETLOCKING_BYCALLER);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We set result to NULL just before this call in case of error.
Fixed by only calling __fsetlocking when result is not NULL.

strip.c: In function ‘handle_elf.constprop’:
strip.c:1270:31: error: null pointer dereference [-Werror=null-dereference]
       elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
                    ~~~~~~~~~~~^~~

src/strip.c:597:37: note: in definition of macro ‘elf_assert’
 #define elf_assert(test) do { if (!(test)) goto illformed; } while (0)
                                     ^~~~

That is the wrong check, we want to check shndxdata, not versiondata here.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
libasm/ChangeLog
libasm/asm_begin.c
src/ChangeLog
src/strip.c