Compare commits

...

2 Commits

Author SHA1 Message Date
Dylan Baker c0fa7879b2 libpkgconf: zero path lists after freeing
ci/woodpecker/push/woodpecker Pipeline was successful Details
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)
2022-06-26 03:12:34 +00:00
Dylan Baker 2d201af326 libpkgconf: Add a helper to zero `pkgconf_list_t`s 2022-06-26 03:12:34 +00:00
3 changed files with 12 additions and 0 deletions

View File

@ -34,6 +34,14 @@ typedef struct {
#define PKGCONF_LIST_INITIALIZER { NULL, NULL, 0 }
static inline void
pkgconf_list_zero(pkgconf_list_t *list)
{
list->head = NULL;
list->tail = NULL;
list->length = 0;
}
static inline void
pkgconf_node_insert(pkgconf_node_t *node, void *data, pkgconf_list_t *list)
{

View File

@ -268,6 +268,8 @@ pkgconf_path_free(pkgconf_list_t *dirlist)
free(pnode->path);
free(pnode);
}
pkgconf_list_zero(dirlist);
}
static char *

View File

@ -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);
}