public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] malloc: Print error when oldsize is not equal to the current size.
@ 2021-03-26 11:05 liqingqing
  2021-04-01  8:51 ` liqingqing
  2022-09-22 19:51 ` DJ Delorie
  0 siblings, 2 replies; 5+ messages in thread
From: liqingqing @ 2021-03-26 11:05 UTC (permalink / raw)
  To: libc-alpha, carlos, dj, Siddhesh Poyarekar; +Cc: wuxu.wu, yebiaoxiang, Liusirui

 This is used to detect errors early.

---
 malloc/malloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 530c792997..243be0da68 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4784,7 +4784,8 @@ _int_realloc(mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
 
   /* oldmem size */
   if (__builtin_expect (chunksize_nomask (oldp) <= CHUNK_HDR_SZ, 0)
-      || __builtin_expect (oldsize >= av->system_mem, 0))
+      || __builtin_expect (oldsize >= av->system_mem, 0)
+      || __builtin_expect (oldsize != chunksize (oldp), 0))
     malloc_printerr ("realloc(): invalid old size");
 
   check_inuse_chunk (av, oldp);
-- 
2.27.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-22 19:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 11:05 [PATCH] malloc: Print error when oldsize is not equal to the current size liqingqing
2021-04-01  8:51 ` liqingqing
2021-04-13 22:14   ` DJ Delorie
2021-04-23  2:23     ` liqingqing
2022-09-22 19:51 ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).