summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>2001-06-21 14:27:14 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>2001-06-21 14:27:14 +0000
commit2bac1eade82fc81061de64caadb54c8fb63955c0 (patch)
tree523dd9db6038fd0d1f89ab61195d021f40c7720d
parent73d5858775cba3291217af4f8b421cf581228a44 (diff)
Panic if we free stuff not in malloc region. (ifdef DIAGNOSTIC)
-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];