mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 14:39:37 +00:00
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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361793
@ -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