summaryrefslogtreecommitdiff
path: root/libelf
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2017-04-19 17:07:46 +0200
committerMark Wielaard <mark@klomp.org>2017-04-19 17:11:08 +0200
commit7114c513fbebcca8b76796b7f64b57447ba383e1 (patch)
tree010b6a0b65aab2d0b29e070478bf35d4661241cc /libelf
parent45ca3b9dfdc730cc6e6420a59ad9cb2613473aa0 (diff)
downloadelfutils-7114c513fbebcca8b76796b7f64b57447ba383e1.tar.gz
libelf: Initialize n to zero in elf_getarsym.
When building with gcc -Os it seems we can inline read_number_entries but if that function fails then n will not be initialized. GCC seems not to realize that in that case n won't be used at all. Explicitly initialize n to zero to prevent a spurious error: 'n' may be used uninitialized in this function [-Werror=maybe-uninitialized] in that case. https://sourceware.org/bugzilla/show_bug.cgi?id=21011 Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog4
-rw-r--r--libelf/elf_getarsym.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 23a4fb93..d425e50a 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-19 Mark Wielaard <mark@klomp.org>
+
+ * elf_getarsym.c (elf_getarsym): Initialize n to zero.
+
2017-03-27 Mark Wielaard <mark@klomp.org>
* elf32_updatefile.c (updatemmap): Always update last_positition.
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index d5f0ba43..1f031fca 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -167,7 +167,7 @@ elf_getarsym (Elf *elf, size_t *ptr)
/* We have an archive. The first word in there is the number of
entries in the table. */
- uint64_t n;
+ uint64_t n = 0;
size_t off = elf->start_offset + SARMAG + sizeof (struct ar_hdr);
if (read_number_entries (&n, elf, &off, index64_p) < 0)
{