We allocate GElf_SymX entries, which are larger than plain GElf_Sym structs.
The check to see whether we could use stack allocation used the correct
sizeof (GElf_SymX), but the check to see if we needed to free was using
the incorrect sizeof (GElf_Sym). Which could cause us to leak memory.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2015-06-18 Mark Wielaard <mjw@redhat.com>
+
+ * nm.c (show_symbols): Check sizeof (sym_mem[0]), not GElf_Sym to
+ known whether or not we stack allocated memory.
+
2015-06-18 Mark Wielaard <mjw@redhat.com>
* strings.c (readelf): Use "<unknown>" if we cannot retrieve section
}
/* Free all memory. */
- if (nentries * sizeof (GElf_Sym) >= MAX_STACK_ALLOC)
+ if (nentries * sizeof (sym_mem[0]) >= MAX_STACK_ALLOC)
free (sym_mem);
obstack_free (&whereob, NULL);