Commit 3fae9da8 authored by Роман Донченко's avatar Роман Донченко Committed by Petr Machata

Fix a memory leak in populate_this_symtab

symbols is only used (and freed) if only_exported_names is true, so
don't allocate it if it's false.
parent 501855a7
......@@ -908,11 +908,15 @@ populate_this_symtab(struct process *proc, const char *filename,
* should be well enough for the number of symbols that we
* typically deal with. */
size_t num_symbols = 0;
struct unique_symbol *symbols = malloc(sizeof(*symbols) * count);
if (symbols == NULL) {
fprintf(stderr, "couldn't insert symbols for -x: %s\n",
strerror(errno));
return -1;
struct unique_symbol *symbols = NULL;
if (!only_exported_names) {
symbols = malloc(sizeof(*symbols) * count);
if (symbols == NULL) {
fprintf(stderr, "couldn't insert symbols for -x: %s\n",
strerror(errno));
return -1;
}
}
GElf_Word secflags[lte->ehdr.e_shnum];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment