summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorotto <>2021-04-09 06:05:21 +0000
committerotto <>2021-04-09 06:05:21 +0000
commitaaa05e7b40eca4afcde651fa92af8734dcfdce56 (patch)
tree7d71a68fe74003fc1e0913f97bcf550afd0babd6
parent2d4ac2ff90fa6ee075a2a1ebf91a5c392f4fdd67 (diff)
downloadopenbsd-aaa05e7b40eca4afcde651fa92af8734dcfdce56.tar.gz
openbsd-aaa05e7b40eca4afcde651fa92af8734dcfdce56.tar.bz2
openbsd-aaa05e7b40eca4afcde651fa92af8734dcfdce56.zip
An extra internal consistency check and a missing stats adjustment. ok tb@
-rw-r--r--src/lib/libc/stdlib/malloc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index 9a4aacc3f9..fb1cc02b85 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc.c,v 1.269 2021/03/09 07:39:28 otto Exp $ */ 1/* $OpenBSD: malloc.c,v 1.270 2021/04/09 06:05:21 otto Exp $ */
2/* 2/*
3 * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> 3 * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> 4 * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -1404,6 +1404,8 @@ ofree(struct dir_info **argpool, void *p, int clear, int check, size_t argsz)
1404 } else { 1404 } else {
1405 /* Validate and optionally canary check */ 1405 /* Validate and optionally canary check */
1406 struct chunk_info *info = (struct chunk_info *)r->size; 1406 struct chunk_info *info = (struct chunk_info *)r->size;
1407 if (info->size != sz)
1408 wrterror(pool, "internal struct corrupt");
1407 find_chunknum(pool, info, p, mopts.chunk_canaries); 1409 find_chunknum(pool, info, p, mopts.chunk_canaries);
1408 if (!clear) { 1410 if (!clear) {
1409 void *tmp; 1411 void *tmp;
@@ -1608,6 +1610,7 @@ orealloc(struct dir_info **argpool, void *p, size_t newsz, void *f)
1608 } 1610 }
1609 if (munmap((char *)r->p + rnewsz, roldsz - rnewsz)) 1611 if (munmap((char *)r->p + rnewsz, roldsz - rnewsz))
1610 wrterror(pool, "munmap %p", (char *)r->p + rnewsz); 1612 wrterror(pool, "munmap %p", (char *)r->p + rnewsz);
1613 STATS_SUB(d->malloc_used, roldsz - rnewsz);
1611 r->size = gnewsz; 1614 r->size = gnewsz;
1612 if (MALLOC_MOVE_COND(gnewsz)) { 1615 if (MALLOC_MOVE_COND(gnewsz)) {
1613 void *pp = MALLOC_MOVE(r->p, gnewsz); 1616 void *pp = MALLOC_MOVE(r->p, gnewsz);