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>
@ -43,8 +44,11 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list,
{
new_allocated = list->allocated + list->allocated / 2 + 1;
if (new_allocated <= list->allocated)
/* Overflow. */
return false;
{
/* Overflow. */
__set_errno (ENOMEM);
return false;
}
}
size_t new_size;