diff options
author | phk <phk@FreeBSD.org> | 2002-04-23 18:50:25 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-04-23 18:50:25 +0000 |
commit | 834fdde07aa3e3bd0fa935c43bf688eb6d0850de (patch) | |
tree | 6c936c2ff234747c4647f56317de343518fec93f /sys/kern | |
parent | 02b1cb77f880a8c74b25c434356740f7c49cb67a (diff) | |
download | FreeBSD-src-834fdde07aa3e3bd0fa935c43bf688eb6d0850de.zip FreeBSD-src-834fdde07aa3e3bd0fa935c43bf688eb6d0850de.tar.gz |
Add a basic sanity check on pointers passed to free(9).
Should be improved by: jeff
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_malloc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index ac8ed51..e168665 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -143,6 +143,10 @@ malloc(size, type, flags) uma_zone_t zone; register struct malloc_type *ksp = type; +#if 0 + if (size == 0) + Debugger("zero size malloc"); +#endif #if defined(INVARIANTS) if (flags == M_WAITOK) KASSERT(curthread->td_intr_nesting_level == 0, @@ -203,6 +207,12 @@ free(addr, type) if (addr == NULL) return; + if ((u_long)addr & 3) { /* XXX: Jeff: find better value for 3 */ + printf("free(9)'ing unaligned pointer %p\n", addr); + Debugger("Don't do that..."); + return; + } + size = 0; mem = (void *)((u_long)addr & (~UMA_SLAB_MASK)); |