From: Michael Tremer Date: Wed, 23 Oct 2024 12:18:52 +0000 (+0000) Subject: tests: Ensure that values are initialized before free X-Git-Tag: 0.9.30~804 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=379f36b37f2de0ca453b9bc9b399eec799ed9b52;p=pakfire.git tests: Ensure that values are initialized before free Signed-off-by: Michael Tremer --- diff --git a/tests/libpakfire/config.c b/tests/libpakfire/config.c index baa6e5723..04bd83fa2 100644 --- a/tests/libpakfire/config.c +++ b/tests/libpakfire/config.c @@ -147,7 +147,8 @@ static int test_parse(const struct test* t) { FAIL: if (f) fclose(f); - pakfire_config_unref(config); + if (config) + pakfire_config_unref(config); return r; } @@ -182,7 +183,8 @@ static int test_parse_multiline(const struct test* t) { FAIL: if (f) fclose(f); - pakfire_config_unref(config); + if (config) + pakfire_config_unref(config); return r; } diff --git a/tests/libpakfire/db.c b/tests/libpakfire/db.c index bc2cf819a..795790b89 100644 --- a/tests/libpakfire/db.c +++ b/tests/libpakfire/db.c @@ -78,6 +78,7 @@ FAIL: } static int test_add_package(const struct test* t) { + struct pakfire_package* package = NULL; struct pakfire_db* db = NULL; struct pakfire_repo* repo = NULL; struct pakfire_archive* archive = NULL; @@ -97,8 +98,6 @@ static int test_add_package(const struct test* t) { ASSERT_SUCCESS(pakfire_archive_open(&archive, t->pakfire, path)); ASSERT(archive); - struct pakfire_package* package = NULL; - // Get package ASSERT_SUCCESS(pakfire_archive_make_package(archive, repo, &package)); ASSERT(package);