diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2008-07-21 17:30:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2008-07-21 17:30:09 +0000 |
commit | adaaa36fe8afda5af0ba42de32cc4f680ec8937b (patch) | |
tree | 869a4599725212c0d2685b52d48cc782c0829ad9 /bin | |
parent | 1520e2a657971f712cfb2ebbc2f122fdcf895dbf (diff) |
Extra sanity checking for afree(); OK deraadt@ and pvalchev@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/ksh/alloc.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bin/ksh/alloc.c b/bin/ksh/alloc.c index 8aaf4ff0726..7e41c2cd5be 100644 --- a/bin/ksh/alloc.c +++ b/bin/ksh/alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alloc.c,v 1.7 2004/02/19 18:51:17 deraadt Exp $ */ +/* $OpenBSD: alloc.c,v 1.8 2008/07/21 17:30:08 millert Exp $ */ /* * Copyright (c) 2002 Marc Espie. * @@ -102,13 +102,20 @@ aresize(void *ptr, size_t size, Area *ap) void afree(void *ptr, Area *ap) { - struct link *l; + struct link *l, *l2; 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 |