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>
|
||||
@ -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;
|
||||
|
Reference in New Issue
Block a user