From c3aa57416566c97888abbc5c2ef4631c8c9e16f0 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 12 Feb 2016 23:59:32 +0100 Subject: Fix GCC6 -Wnull-dereference warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- libasm/ChangeLog | 5 +++++ libasm/asm_begin.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'libasm') diff --git a/libasm/ChangeLog b/libasm/ChangeLog index beb6211c..a8ac2c7c 100644 --- a/libasm/ChangeLog +++ b/libasm/ChangeLog @@ -1,3 +1,8 @@ +2016-02-12 Mark Wielaard + + * asm_begin.c (prepare_text_output): Only call __fsetlocking when + result isn't NULL. + 2015-10-05 Josh Stone * Makefile.am (libasm.so): Add AM_V_CCLD and AM_V_at silencers. diff --git a/libasm/asm_begin.c b/libasm/asm_begin.c index ff4d94c2..dc83cd8b 100644 --- a/libasm/asm_begin.c +++ b/libasm/asm_begin.c @@ -58,8 +58,8 @@ prepare_text_output (AsmCtx_t *result) free (result); result = NULL; } - - __fsetlocking (result->out.file, FSETLOCKING_BYCALLER); + else + __fsetlocking (result->out.file, FSETLOCKING_BYCALLER); } return result; -- cgit v1.2.3