Add reference counting to Defaults bindings.
Previously, we checked that the previous entry's binding pointer was not the same while freeing. However, to be able to merge Defaults records we cannot rely on Defaults entries with the same binding being immediately adjacent. This removes the prev_binding checks in favor of a reference count which allows us to plug the memory leak in cvtsudoers when merging Defaults.
This commit is contained in:
@@ -252,7 +252,8 @@ ldif_store_options(struct sudoers_parse_tree *parse_tree,
|
||||
sudo_fatalx(U_("%s: %s"), __func__,
|
||||
U_("unable to allocate memory"));
|
||||
}
|
||||
TAILQ_INIT(d->binding);
|
||||
TAILQ_INIT(&d->binding->members);
|
||||
d->binding->refcnt = 1;
|
||||
d->type = DEFAULTS;
|
||||
d->op = sudo_ldap_parse_option(ls->str, &var, &val);
|
||||
if ((d->var = strdup(var)) == NULL) {
|
||||
|
Reference in New Issue
Block a user