These errors were reported by cppcheck: bsd-user/elfload.c:1076: error: Memory leak: s bsd-user/elfload.c:1079: error: Memory leak: syms
Cc: Blue Swirl <blauwir...@gmail.com> Signed-off-by: Stefan Weil <w...@mail.berlios.de> --- bsd-user/elfload.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index 7374912..313ddc6 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -1072,11 +1072,16 @@ static void load_symbols(struct elfhdr *hdr, int fd) /* Now know where the strtab and symtab are. Snarf them. */ s = malloc(sizeof(*s)); syms = malloc(symtab.sh_size); - if (!syms) + if (!syms) { + free(s); return; + } s->disas_strtab = strings = malloc(strtab.sh_size); - if (!s->disas_strtab) + if (!s->disas_strtab) { + free(s); + free(syms); return; + } lseek(fd, symtab.sh_offset, SEEK_SET); if (read(fd, syms, symtab.sh_size) != symtab.sh_size) -- 1.7.2.3