summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorniklas <niklas@openbsd.org>2001-06-21 14:27:13 +0000
committerniklas <niklas@openbsd.org>2001-06-21 14:27:13 +0000
commitdb98b60b7e9b5af8e399f74df0bfcd6528826ad0 (patch)
treeabe662bbc2cf2e330fa083453915d596b1ab0c9b /sys/kern/kern_malloc.c
parentManpage for cz(4) (diff)
downloadwireguard-openbsd-db98b60b7e9b5af8e399f74df0bfcd6528826ad0.tar.xz
wireguard-openbsd-db98b60b7e9b5af8e399f74df0bfcd6528826ad0.zip
Panic if we free stuff not in malloc region. (ifdef DIAGNOSTIC)
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 1998ba8022b..8a51c816f2e 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.31 2001/05/14 08:03:13 angelos Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.32 2001/06/21 14:27:13 niklas Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -341,6 +341,12 @@ free(addr, type)
return;
#endif
+#ifdef DIAGNOSTIC
+ if (addr < (void *)kmembase || addr >= (void *)kmemlimit)
+ panic("free of non-malloced addr %p type %s", addr,
+ memname[type]);
+#endif
+
kup = btokup(addr);
size = 1 << kup->ku_indx;
kbp = &bucket[kup->ku_indx];