1
0
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:
Florian Weimer
2017-08-30 20:10:56 +02:00
parent a9da0bb266
commit 5898f4548e
4 changed files with 49 additions and 3 deletions

View File

@ -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)
{