From: Aleksey Katargin Date: Wed, 19 Oct 2016 08:05:11 +0000 (+0500) Subject: conffile: cleanup section children and tail on data remove X-Git-Tag: release_3_0_13~135^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=573036962ed7dc43e0613657a4ecf6b0f3b9c054;p=thirdparty%2Ffreeradius-server.git conffile: cleanup section children and tail on data remove Signed-off-by: Aleksey Katargin --- diff --git a/src/main/conffile.c b/src/main/conffile.c index 611c3867ab5..df78184bd43 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -3624,6 +3624,7 @@ void *cf_data_remove(CONF_SECTION *cs, char const *name) { CONF_DATA mycd; CONF_DATA *cd; + CONF_ITEM *ci, *it; void *data; if (!cs || !name) return NULL; @@ -3637,6 +3638,20 @@ void *cf_data_remove(CONF_SECTION *cs, char const *name) cd = rbtree_finddata(cs->data_tree, &mycd); if (!cd) return NULL; + ci = cf_data_to_item(cd); + if (cs->children == ci) { + cs->children = ci->next; + if (cs->tail == ci) cs->tail = NULL; + } else { + for (it = cs->children; it; it = it->next) { + if (it->next == ci) { + it->next = ci->next; + if (cs->tail == ci) cs->tail = it; + break; + } + } + } + talloc_set_destructor(cd, NULL); /* Disarm the destructor */ rbtree_deletebydata(cs->data_tree, &mycd);