aboutsummaryrefslogtreecommitdiff
path: root/stand/libsa/zalloc_malloc.c
diff options
context:
space:
mode:
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