summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2016-02-12 23:59:32 +0100
committerMark Wielaard <mjw@redhat.com>2016-02-22 12:09:25 +0100
commitc3aa57416566c97888abbc5c2ef4631c8c9e16f0 (patch)
treee44d19e5664942eb7868e2e2412648d0c772bb50 /src
parent2f289fa9e34c7cf67403907a354abe8ecaf380d2 (diff)
downloadelfutils-c3aa57416566c97888abbc5c2ef4631c8c9e16f0.tar.gz
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>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/strip.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1c935d95..29782404 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2016-02-12 Mark Wielaard <mjw@redhat.com>
+
+ * strip.c (handle_elf): Correct elf_assert shndxdata check.
+
2016-02-09 Mark Wielaard <mjw@redhat.com>
* readelf.c (read_encoded): Move up.
diff --git a/src/strip.c b/src/strip.c
index 06d7cfd8..a6042445 100644
--- a/src/strip.c
+++ b/src/strip.c
@@ -1267,8 +1267,10 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
shndxdata = elf_getdata (shdr_info[shdr_info[cnt].symtab_idx].scn,
NULL);
- elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
- >= shdr_info[cnt].data->d_size / elsize);
+ elf_assert (shndxdata != NULL
+ && shndxdata->d_buf != NULL
+ && ((shndxdata->d_size / sizeof (Elf32_Word))
+ >= shdr_info[cnt].data->d_size / elsize));
}
if (shdr_info[cnt].version_idx != 0)