From e2efa436442cdd238a06b5e311f9ff030aa1042d Mon Sep 17 00:00:00 2001 From: Kai Wang Date: Wed, 21 Jul 2010 12:30:58 +0000 Subject: [PATCH] Fix a memory leak. Obtained from: elftoolchain MFC after: 1 month --- lib/libelf/elf_update.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libelf/elf_update.c b/lib/libelf/elf_update.c index 2d7681faf648..69bbaac8a869 100644 --- a/lib/libelf/elf_update.c +++ b/lib/libelf/elf_update.c @@ -855,11 +855,13 @@ _libelf_write_elf(Elf *e, off_t newsize) e->e_u.e_elf.e_phdr.e_phdr64 = NULL; } + free(newfile); + return (rc); error: - if (newfile) - free(newfile); + free(newfile); + return ((off_t) -1); }