diff options
author | Chet Ramey <chet.ramey@case.edu> | 2021-11-17 16:44:19 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2021-11-17 16:44:19 -0500 |
commit | fed42742e0b33b358610bf62c7474f55e6465205 (patch) | |
tree | a9ef2585f16b5c39749f8366b01c71da894daf72 | |
parent | ce23728687ce9e584333367075c9deef413553fa (diff) | |
download | bash-fed42742e0b33b358610bf62c7474f55e6465205.tar.gz |
Bash-5.1 patch 9: fix bash malloc implementation of malloc_usable_size
-rw-r--r-- | lib/malloc/malloc.c | 13 | ||||
-rw-r--r-- | patchlevel.h | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c index 439f8ef1..92e6efa5 100644 --- a/lib/malloc/malloc.c +++ b/lib/malloc/malloc.c @@ -1286,13 +1286,12 @@ malloc_usable_size (mem) p = (union mhead *) ap - 1; } - /* XXX - should we return 0 if ISFREE? */ - maxbytes = binsize(p->mh_index); - - /* So the usable size is the maximum number of bytes in the bin less the - malloc overhead */ - maxbytes -= MOVERHEAD + MSLOP; - return (maxbytes); + /* return 0 if ISFREE */ + if (p->mh_alloc == ISFREE) + return 0; + + /* Since we use bounds checking, the usable size is the last requested size. */ + return (p->mh_nbytes); } #if !defined (NO_VALLOC) diff --git a/patchlevel.h b/patchlevel.h index 10fde2ee..17586ff7 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 8 +#define PATCHLEVEL 9 #endif /* _PATCHLEVEL_H_ */ |