summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/malloc.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2016-11-03 18:52:41 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2016-11-03 18:52:41 +0000
commitdb0143943b8f507d71ab8382ccb3d557bb2b28f4 (patch)
tree33ea1c6c4205bdca7563de95c57ba160cb834847 /lib/libc/stdlib/malloc.c
parent290031f9d547e986401ab390cba2229281c48b80 (diff)
small tweak to also check canaries if F is in effect
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r--lib/libc/stdlib/malloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index 62e5fe24694..873db60dd5c 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: malloc.c,v 1.209 2016/10/31 10:06:56 otto Exp $ */
+/* $OpenBSD: malloc.c,v 1.210 2016/11/03 18:51:49 otto Exp $ */
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -1039,7 +1039,7 @@ find_chunknum(struct dir_info *d, struct region_info *r, void *ptr, int check)
/* Find the chunk number on the page */
chunknum = ((uintptr_t)ptr & MALLOC_PAGEMASK) >> info->shift;
- if (check && mopts.chunk_canaries && info->size > 0) {
+ if (check && info->size > 0) {
validate_canary(d, ptr, info->bits[info->offset + chunknum],
info->size);
}
@@ -1343,8 +1343,10 @@ ofree(struct dir_info *argpool, void *p)
void *tmp;
int i;
+ /* Delayed free or canaries? Extra check */
+ if (!mopts.malloc_freenow || mopts.chunk_canaries)
+ find_chunknum(pool, r, p, mopts.chunk_canaries);
if (!mopts.malloc_freenow) {
- find_chunknum(pool, r, p, 1);
if (mopts.malloc_junk && sz > 0)
memset(p, SOME_FREEJUNK, sz);
i = getrbyte(pool) & MALLOC_DELAYED_CHUNK_MASK;