diff options
author | 2017-08-15 17:57:57 +0000 | |
---|---|---|
committer | 2017-08-15 17:57:57 +0000 | |
commit | 526c36bd412f9217de682beefaada749b201d675 (patch) | |
tree | 4c27838875de015bb273c8b5167ec590a30895f6 /bin/ksh/alloc.c | |
parent | Convert hand rolled sockaddr checks to the nam2sin functions. (diff) | |
download | wireguard-openbsd-526c36bd412f9217de682beefaada749b201d675.tar.xz wireguard-openbsd-526c36bd412f9217de682beefaada749b201d675.zip |
Remove expensive pointer check in afree()
The check added in rev 1.8 walks the whole freelist to catch cases where
an unknown pointer is passed to afree(); but it can't catch cases
whether the struct link has been corrupted by an invalid memory write.
And it becomes very expensive when you have lots of items in an area
(for example with a huge HISTSIZE).
Discussed with & ok millert@ tb@
Diffstat (limited to 'bin/ksh/alloc.c')
-rw-r--r-- | bin/ksh/alloc.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/bin/ksh/alloc.c b/bin/ksh/alloc.c index 508ece1d1ab..e1de35af5fa 100644 --- a/bin/ksh/alloc.c +++ b/bin/ksh/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.16 2017/05/29 13:09:17 tb Exp $ */ +/* $OpenBSD: alloc.c,v 1.17 2017/08/15 17:57:57 jca Exp $ */ /* Public domain, like most of the rest of ksh */ @@ -111,20 +111,12 @@ aresize(void *ptr, size_t size, Area *ap) void afree(void *ptr, Area *ap) { - struct link *l, *l2; + struct link *l; if (!ptr) return; l = P2L(ptr); - - for (l2 = ap->freelist; l2 != NULL; l2 = l2->next) { - if (l == l2) - break; - } - if (l2 == NULL) - internal_errorf(1, "afree: %p not present in area %p", ptr, ap); - if (l->prev) l->prev->next = l->next; else |