diff options
| author | otto <> | 2021-04-09 06:05:21 +0000 | 
|---|---|---|
| committer | otto <> | 2021-04-09 06:05:21 +0000 | 
| commit | b4499c43f4b32d2e5e054187f8f0e5bfd8299e02 (patch) | |
| tree | 7d71a68fe74003fc1e0913f97bcf550afd0babd6 /src/lib/libc/stdlib/malloc.c | |
| parent | e3d1ed16d000aa151144fb4a5e41cd02144b2cc2 (diff) | |
| download | openbsd-b4499c43f4b32d2e5e054187f8f0e5bfd8299e02.tar.gz openbsd-b4499c43f4b32d2e5e054187f8f0e5bfd8299e02.tar.bz2 openbsd-b4499c43f4b32d2e5e054187f8f0e5bfd8299e02.zip | |
An extra internal consistency check and a missing stats adjustment. ok tb@
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -rw-r--r-- | src/lib/libc/stdlib/malloc.c | 5 | 
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); | 
