diff options
Diffstat (limited to 'lib/libc/stdlib/malloc.c')
-rw-r--r-- | lib/libc/stdlib/malloc.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index ce869412f5b..0296985e5b5 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.195 2016/09/01 10:41:02 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.196 2016/09/18 13:46:28 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -376,6 +376,11 @@ unmap(struct dir_info *d, void *p, size_t sz) for (i = 0; i < mopts.malloc_cache; i++) { r = &d->free_regions[(i + offset) & (mopts.malloc_cache - 1)]; if (r->p == NULL) { + if (mopts.malloc_junk && !mopts.malloc_freeunmap) { + size_t amt = mopts.malloc_junk == 1 ? + MALLOC_MAXCHUNK : sz; + memset(p, SOME_FREEJUNK, amt); + } if (mopts.malloc_hint) madvise(p, sz, MADV_FREE); if (mopts.malloc_freeunmap) @@ -1336,11 +1341,6 @@ ofree(struct dir_info *argpool, void *p) } STATS_SUB(pool->malloc_guarded, mopts.malloc_guard); } - if (mopts.malloc_junk && !mopts.malloc_freeunmap) { - size_t amt = mopts.malloc_junk == 1 ? MALLOC_MAXCHUNK : - PAGEROUND(sz) - mopts.malloc_guard; - memset(p, SOME_FREEJUNK, amt); - } unmap(pool, p, PAGEROUND(sz)); delete(pool, r); } else { |