mirror of
https://sourceware.org/git/glibc.git
synced 2025-10-26 00:57:39 +03:00
malloc: Improve checked_request2size
Change checked_request2size to return SIZE_MAX for huge inputs. This ensures large allocation requests stay large and can't be confused with a small allocation. As a result several existing checks against PTRDIFF_MAX become redundant. Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
@@ -275,12 +275,12 @@ realloc_check (void *oldmem, size_t bytes)
|
||||
malloc_printerr ("realloc(): invalid pointer");
|
||||
const INTERNAL_SIZE_T oldsize = chunksize (oldp);
|
||||
|
||||
chnb = checked_request2size (rb);
|
||||
if (chnb == 0)
|
||||
if (rb > PTRDIFF_MAX)
|
||||
{
|
||||
__set_errno (ENOMEM);
|
||||
goto invert;
|
||||
}
|
||||
chnb = checked_request2size (rb);
|
||||
|
||||
__libc_lock_lock (main_arena.mutex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user