dhclient: Fix a logic bug remove_protocol().
A logic bug in remove_protocol() meant that it would remove (leak) all structures in the list preceding the one intended for removal. PR: 245971 Submitted by: joost@jodocus.org (original version) MFC after: 1 week
This commit is contained in:
parent
e9ee2675cb
commit
0006082054
@ -474,13 +474,16 @@ add_protocol(const char *name, int fd, void (*handler)(struct protocol *),
|
||||
void
|
||||
remove_protocol(struct protocol *proto)
|
||||
{
|
||||
struct protocol *p, *next;
|
||||
struct protocol *p, *prev;
|
||||
|
||||
for (p = protocols; p; p = next) {
|
||||
next = p->next;
|
||||
for (p = protocols, prev = NULL; p != NULL; prev = p, p = p->next) {
|
||||
if (p == proto) {
|
||||
if (prev == NULL)
|
||||
protocols = p->next;
|
||||
else
|
||||
prev->next = p->next;
|
||||
free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user