libmpm

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

commit 31c58b54ba62f39b295e83fbe02a442f0e1857b3
parent 222d4b92bf2422fd799df7dab58ff355ed2d247f
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Sun, 28 May 2017 19:09:20 +0200

Fix(Compile): Some leaks in installation

Diffstat:
Msrc/compile.c | 6+++++-
Mtests/test_compile.c | 5+----
Mtests/test_packer.c | 2++
3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/compile.c b/src/compile.c @@ -213,7 +213,11 @@ bool install_archive(packer_t *ctx) { ptr = package_install_init(ctx); if (ptr == NULL) - goto end; + { + recursive_delete(ctx->out_dir); + packer_free(ctx); + return ret; + } if (before_package(ptr) == false) goto end; diff --git a/tests/test_compile.c b/tests/test_compile.c @@ -200,6 +200,7 @@ TEST(full_install_2) { packer_t *ctx; ctx = packer_init_archive(PACKAGE_OUTPUT_FN); + set_malloc_fail(0); TEST_ASSERT(install_archive(ctx) == false, "Error did not raise"); @@ -218,22 +219,18 @@ TEST(full_install_2) { ctx = packer_init_archive(PACKAGE_OUTPUT_FN); set_fork_fail(2); TEST_ASSERT(install_archive(ctx) == false, "Error did not raise"); - recursive_delete(ctx->out_dir); ctx = packer_init_archive(PACKAGE_OUTPUT_FN); set_fork_fail(3); TEST_ASSERT(install_archive(ctx) == false, "Error did not raise"); - recursive_delete(ctx->out_dir); ctx = packer_init_archive(PACKAGE_OUTPUT_FN); set_fork_fail(4); TEST_ASSERT(install_archive(ctx) == false, "Error did not raise"); - recursive_delete(ctx->out_dir); ctx = packer_init_archive(PACKAGE_OUTPUT_FN); set_fork_fail(5); TEST_ASSERT(install_archive(ctx) == false, "Error did not raise"); - recursive_delete(ctx->out_dir); return TEST_SUCCESS; } diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -593,6 +593,8 @@ TEST(get_file_information) { set_stat_fail(0); TEST_ASSERT(get_file_information(file) == false, "Error did not raise"); + free(file->fn); + free(file); return TEST_SUCCESS; }