diff options
author | Qingqing Li <liqingqing3@huawei.com> | 2022-09-22 15:32:56 -0400 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2022-09-22 15:32:56 -0400 |
commit | 774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6 (patch) | |
tree | 609c8125648c664b7a8362dcc0b0af1eceff8548 /malloc | |
parent | de477abcaaabb1f9815cb63876637a47a95e7ac1 (diff) | |
download | glibc-774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6.tar glibc-774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6.tar.gz glibc-774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6.tar.bz2 glibc-774d43f27dbc730ee4b8b37bce4d5b3d5c0b74b6.zip |
malloc: Print error when oldsize is not equal to the current size.
This is used to detect errors early. The read of the oldsize is
not protected by any lock, so check this value to avoid causing
bigger mistakes.
Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/malloc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index bfe1955737..67ac661256 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4803,7 +4803,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); |