1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-06-13 19:21:36 +03:00

Replace check_mul_overflow_size_t with __builtin_mul_overflow

Checked on x86_64-linux-gnu and i686-linux-gnu.

	* malloc/alloc_buffer_alloc_array.c (__libc_alloc_buffer_alloc_array):
	Use __builtin_mul_overflow in place of check_mul_overflow_size_t.
	* malloc/dynarray_emplace_enlarge.c (__libc_dynarray_emplace_enlarge):
	Likewise.
	* malloc/dynarray_resize.c (__libc_dynarray_resize): Likewise.
	* malloc/reallocarray.c (__libc_reallocarray): Likewise.
	* malloc/malloc-internal.h (check_mul_overflow_size_t): Remove
	function.
	* support/blob_repeat.c (check_mul_overflow_size_t,
	(minimum_stride_size, support_blob_repeat_allocate): Likewise.
This commit is contained in:
Adhemerval Zanella
2018-12-21 09:49:37 -02:00
parent 09104e5ba4
commit 0253580a75
7 changed files with 21 additions and 53 deletions

View File

@ -17,7 +17,6 @@
<http://www.gnu.org/licenses/>. */
#include <alloc_buffer.h>
#include <malloc-internal.h>
#include <libc-pointer-arith.h>
void *
@ -28,7 +27,7 @@ __libc_alloc_buffer_alloc_array (struct alloc_buffer *buf, size_t element_size,
/* The caller asserts that align is a power of two. */
size_t aligned = ALIGN_UP (current, align);
size_t size;
bool overflow = check_mul_overflow_size_t (element_size, count, &size);
bool overflow = __builtin_mul_overflow (element_size, count, &size);
size_t new_current = aligned + size;
if (!overflow /* Multiplication did not overflow. */
&& aligned >= current /* No overflow in align step. */