mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 19:00:07 +00:00
Update.
2002-08-03 Jakub Jelinek <jakub@redhat.com> Ulrich Drepper <drepper@redhat.com> * malloc/malloc.c (public_cALLOc): Only divide if at least one of arguments is big enough to cause an overflow.
This commit is contained in:
parent
7abb683a13
commit
d9af917d07
@ -1,3 +1,9 @@
|
||||
2002-08-03 Jakub Jelinek <jakub@redhat.com>
|
||||
Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* malloc/malloc.c (public_cALLOc): Only divide if at least one of
|
||||
arguments is big enough to cause an overflow.
|
||||
|
||||
2002-08-03 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* assert/assert.c: Use hidden_def not INTDEF.
|
||||
|
@ -488,6 +488,9 @@ Void_t *(*__morecore)(ptrdiff_t) = __default_morecore;
|
||||
#endif /* _LIBC */
|
||||
#endif /* USE_DL_PREFIX */
|
||||
|
||||
#ifndef _LIBC
|
||||
#define __builtin_expect(expr, val) (expr)
|
||||
#endif
|
||||
|
||||
/*
|
||||
HAVE_MEMCPY should be defined if you are not otherwise using
|
||||
@ -3466,10 +3469,14 @@ public_cALLOc(size_t n, size_t elem_size)
|
||||
|
||||
/* size_t is unsigned so the behavior on overflow is defined. */
|
||||
bytes = n * elem_size;
|
||||
#define HALF_INTERNAL_SIZE_T \
|
||||
(((INTERNAL_SIZE_T) 1) << (8 * sizeof (INTERNAL_SIZE_T) / 2))
|
||||
if (__builtin_expect ((n | elem_size) >= HALF_INTERNAL_SIZE_T, 0)) {
|
||||
if (bytes / elem_size != n) {
|
||||
MALLOC_FAILURE_ACTION;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (hook != NULL) {
|
||||
sz = bytes;
|
||||
|
Loading…
Reference in New Issue
Block a user