svashisht / rpms / bash

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