aboutsummaryrefslogtreecommitdiff
path: root/stand/libsa/zalloc_malloc.c
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2020-08-29 21:05:43 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2020-08-29 21:05:43 +0000
commited19b7c5259d293e42ca4fc7c9eaa29cfcdcfbf3 (patch)
treeb2e53a71fbad08b676a1f568e6f1ae263c16854e /stand/libsa/zalloc_malloc.c
parent5d4bf0578f0c665f2f28f8ca0970a3368fad6e7b (diff)
Notes
Diffstat (limited to 'stand/libsa/zalloc_malloc.c')
-rw-r--r--stand/libsa/zalloc_malloc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/stand/libsa/zalloc_malloc.c b/stand/libsa/zalloc_malloc.c
index 98e28b8ef7f5..215e07d34a84 100644
--- a/stand/libsa/zalloc_malloc.c
+++ b/stand/libsa/zalloc_malloc.c
@@ -52,6 +52,10 @@ void mallocstats(void);
static void *Malloc_align(size_t, size_t);
+#ifndef MIN
+# define MIN(a,b) ((a) <= (b)) ? (a) : (b)
+#endif
+
void *
Malloc(size_t bytes, const char *file __unused, int line __unused)
{
@@ -119,9 +123,14 @@ Free(void *ptr, const char *file, int line)
ptr, file, line);
return;
}
- if (res->ga_Magic != GAMAGIC)
+ if (res->ga_Magic != GAMAGIC) {
+ size_t dump_bytes;
+
+ dump_bytes = MIN((ptr - MallocPool.mp_Base), 512);
+ hexdump(ptr - dump_bytes, dump_bytes);
panic("free: guard1 fail @ %p from %s:%d",
ptr, file, line);
+ }
res->ga_Magic = GAFREE;
#endif
#ifdef USEENDGUARD