From 5898f4548efdcd7c0fd437a74eeb80facc51a117 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 30 Aug 2017 20:10:56 +0200 Subject: dynarray: Set errno on overflow-induced allocation failure This allows the caller to return directly on such an error, with an appropriate errno value. --- malloc/dynarray_emplace_enlarge.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'malloc/dynarray_emplace_enlarge.c') diff --git a/malloc/dynarray_emplace_enlarge.c b/malloc/dynarray_emplace_enlarge.c index dfc70017ce..0fb032765c 100644 --- a/malloc/dynarray_emplace_enlarge.c +++ b/malloc/dynarray_emplace_enlarge.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include #include @@ -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; -- cgit v1.2.3