From a2d4bd08bbdbc6315dacfcf65cd93ee82a67a44f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 5 Feb 2015 11:42:46 +0100 Subject: [PATCH] Fix some memleaks --- libr/bin/format/elf/elf.c | 6 ++++++ libr/fs/fs.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index 0f1cdb094a..1d9f985e87 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1161,10 +1161,14 @@ if ( } if (strtab_section->sh_size> ST32_MAX) { eprintf ("size (syms strtab)"); + free (ret); + free (strtab); return NULL; } if ((strtab = (char *)calloc (1, 8+strtab_section->sh_size)) == NULL) { eprintf ("malloc (syms strtab)"); + free (ret); + free (strtab); return NULL; } if (r_buf_read_at (bin->b, strtab_section->sh_offset, @@ -1219,6 +1223,7 @@ if ( } else continue; if ((ret = realloc (ret, (ret_ctr + 1) * sizeof (struct r_bin_elf_symbol_t))) == NULL) { perror ("realloc (symbols|imports)"); + free (sym); return NULL; } #if 0 @@ -1302,6 +1307,7 @@ if ( } else break; } } + free (strtab); return ret; } diff --git a/libr/fs/fs.c b/libr/fs/fs.c index 17e8c181ac..9d694fe9ef 100644 --- a/libr/fs/fs.c +++ b/libr/fs/fs.c @@ -580,8 +580,10 @@ R_API int r_fs_prompt (RFS *fs, const char *root) { fgets (buf, sizeof (buf)-1, stdin); if (feof (stdin)) break; buf[strlen (buf)-1] = '\0'; - if (!strcmp (buf, "q") || !strcmp (buf, "exit")) + if (!strcmp (buf, "q") || !strcmp (buf, "exit")) { + r_list_free (list); return R_TRUE; + } if (buf[0]=='!') { r_sandbox_system (buf+1, 1); } else