From 6c55d7bfc0e88ddeb8c4538ae347cd0d208df390 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Mon, 27 Feb 2023 13:45:12 +0100 Subject: [PATCH] Refix use-after-free --- libpkg/pkg_config.c | 1 - tests/frontend/pkg.sh | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libpkg/pkg_config.c b/libpkg/pkg_config.c index 264e714fcb..83a8c76616 100644 --- a/libpkg/pkg_config.c +++ b/libpkg/pkg_config.c @@ -1208,7 +1208,6 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags) ucl_object_replace_key(config, ucl_object_ref(cur), key, strlen(key), true); } } - ucl_object_unref(ncfg); ncfg = NULL; it = NULL; while ((cur = ucl_iterate_object(config, &it, true))) { diff --git a/tests/frontend/pkg.sh b/tests/frontend/pkg.sh index 5f1919ce13..b1717de4b8 100755 --- a/tests/frontend/pkg.sh +++ b/tests/frontend/pkg.sh @@ -6,7 +6,8 @@ tests_init \ pkg_no_database \ pkg_config_defaults \ pkg_create_manifest_bad_syntax \ - pkg_repo_load_order + pkg_repo_load_order \ + double_entry pkg_no_database_body() { atf_skip_on Linux Test fails on Linux @@ -87,3 +88,16 @@ pkg_repo_load_order_body() -s exit:0 \ echo $out } + +double_entry_body() +{ + cat >> pkg.conf <