From c0fa7879b2c6674353ddf781a349825f19c5b996 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 1 Apr 2022 14:15:43 -0700 Subject: [PATCH] libpkgconf: zero path lists after freeing This is required to make the pointer safely re-usable after being freed, otherwise the list still says that it has nodes, but they point nowhere. This is particularly important for libpkgconf, if a caller needs to re-enter the library after freeing a path in a static path (such as the default personality) --- libpkgconf/path.c | 2 ++ libpkgconf/tuple.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 5884ed7..e591298 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -268,6 +268,8 @@ pkgconf_path_free(pkgconf_list_t *dirlist) free(pnode->path); free(pnode); } + + pkgconf_list_zero(dirlist); } static char * diff --git a/libpkgconf/tuple.c b/libpkgconf/tuple.c index 2d550d8..0199709 100644 --- a/libpkgconf/tuple.c +++ b/libpkgconf/tuple.c @@ -390,4 +390,6 @@ pkgconf_tuple_free(pkgconf_list_t *list) PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node) pkgconf_tuple_free_entry(node->data, list); + + pkgconf_list_zero(list); }