diff options
author | Petr Machata <pmachata@redhat.com> | 2013-01-09 17:40:18 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2013-03-08 22:55:34 +0100 |
commit | f0d248aab596acd802668990793413180bb21f79 (patch) | |
tree | e597f8638679f5c5928858d292803e225d5f462a | |
parent | 6bf1e6abb46255456d307bb73432d8733978e5fd (diff) | |
download | ltrace-f0d248aab596acd802668990793413180bb21f79.tar.gz |
Plug a leak in error path of ltelf_read_main_binary
-rw-r--r-- | ltrace-elf.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/ltrace-elf.c b/ltrace-elf.c index 0ecdc38..aeb643e 100644 --- a/ltrace-elf.c +++ b/ltrace-elf.c @@ -873,8 +873,8 @@ read_module(struct library *lib, struct process *proc, /* Note that we set soname and pathname as soon as they are * allocated, so in case of further errors, this get released - * when LIB is release, which should happen in the caller when - * we return error. */ + * when LIB is released, which should happen in the caller + * when we return error. */ if (lib->pathname == NULL) { char *pathname = strdup(filename); @@ -968,14 +968,13 @@ ltelf_read_main_binary(struct process *proc, const char *path) * that. Presumably we could read the DSOs from the process * memory image, but that's not currently done. */ char *fname = pid2name(proc->pid); - if (fname == NULL) - return NULL; - if (read_module(lib, proc, fname, 0, 1) < 0) { + if (fname == NULL + || read_module(lib, proc, fname, 0, 1) < 0) { library_destroy(lib); free(lib); - return NULL; + lib = NULL; } - free(fname); + free(fname); return lib; } |