mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
dynarray: Set errno on overflow-induced allocation failure
This allows the caller to return directly on such an error, with an appropriate errno value.
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <dynarray.h>
|
||||
#include <errno.h>
|
||||
#include <malloc-internal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -38,7 +39,11 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
|
||||
|
||||
size_t new_size_bytes;
|
||||
if (check_mul_overflow_size_t (size, element_size, &new_size_bytes))
|
||||
return false;
|
||||
{
|
||||
/* Overflow. */
|
||||
__set_errno (ENOMEM);
|
||||
return false;
|
||||
}
|
||||
void *new_array;
|
||||
if (list->array == scratch)
|
||||
{
|
||||
|
Reference in New Issue
Block a user