[ltrace-commits] 01/01: Fix a memory leak in populate_this_symtab
Petr Machata
pmachata-guest at moszumanska.debian.org
Fri Apr 10 12:25:48 UTC 2015
This is an automated email from the git hooks/post-receive script.
pmachata-guest pushed a commit to branch master
in repository ltrace.
commit 138cf43e330dd54d9da3c20d13f5f5332f87a6e5
Author: Роман Донченко <dpb at corrigendum.ru>
Date: Fri Apr 10 01:16:06 2015 +0300
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.
---
ltrace-elf.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/ltrace-elf.c b/ltrace-elf.c
index 24d02f0..f439cb0 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -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];
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/ltrace.git
More information about the ltrace-commits
mailing list