From 87ec66278f0e37a80397389521d84a544843f3f3 Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Fri, 23 Feb 2024 21:07:48 +0900 Subject: [PATCH] ccan: Add freed pointer checking to delete strset member Add to set freed entry pointer to NULL then check it if NULL. Signed-off-by: Tokunori Ikegami --- ccan/ccan/strset/strset.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ccan/ccan/strset/strset.c b/ccan/ccan/strset/strset.c index 06b0d7a76c..e960575c95 100644 --- a/ccan/ccan/strset/strset.c +++ b/ccan/ccan/strset/strset.c @@ -194,6 +194,7 @@ char *strset_del(struct strset *set, const char *member) /* Sew empty string back so remaining logic works */ free(n->u.n); + n->u.n = NULL; n->u.s = empty_str; break; } @@ -202,13 +203,14 @@ char *strset_del(struct strset *set, const char *member) if (n->u.n->byte_num < len) { c = bytes[n->u.n->byte_num]; direction = (c >> n->u.n->bit_num) & 1; - } else + } else { direction = 0; + } n = &n->u.n->child[direction]; } /* Did we find it? */ - if (!streq(member, n->u.s)) { + if (!n->u.s || !streq(member, n->u.s)) { errno = ENOENT; return NULL; }