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>
/* 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);