libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 092e7adc0c4b75a83defc14dc09520600cc07d60
parent fb3a8b8c63dd84682bbe0cc64baa2d0fef6966f0
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue,  2 May 2017 15:42:23 +0200

Fix(Packer): Leaks in packer in case of an error

Diffstat:
Msrc/packer.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/packer.c b/src/packer.c @@ -525,7 +525,10 @@ static bool get_file_information(packer_file_t *file) { chunk = malloc(file_size); if (chunk == NULL) + { + free(file_content); return false; + } /* Compress file */ stream.zalloc = NULL; @@ -544,6 +547,7 @@ static bool get_file_information(packer_file_t *file) { file->content = malloc(file->file_size); if (file->content == NULL) { + free(file_content); free(chunk); return false; } @@ -591,6 +595,7 @@ static bool read_files_from_dir(const char *dir_name, mlist_t **files, mlist_t * if (get_file_information(file) == false) { packer_file_free(file); + free(file); goto error; } list_add((*files), file, sizeof(*file));