mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-10 07:10:06 +00:00
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>
This commit is contained in:
parent
de477abcaa
commit
774d43f27d
@ -4803,7 +4803,8 @@ _int_realloc (mstate av, mchunkptr oldp, INTERNAL_SIZE_T oldsize,
|
|||||||
|
|
||||||
/* oldmem size */
|
/* oldmem size */
|
||||||
if (__builtin_expect (chunksize_nomask (oldp) <= CHUNK_HDR_SZ, 0)
|
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");
|
malloc_printerr ("realloc(): invalid old size");
|
||||||
|
|
||||||
check_inuse_chunk (av, oldp);
|
check_inuse_chunk (av, oldp);
|
||||||
|
Loading…
Reference in New Issue
Block a user