From f5ea6c70bdaa55e3709858490164752dc8c30945 Mon Sep 17 00:00:00 2001 From: daan Date: Fri, 17 Dec 2021 13:40:39 -0800 Subject: [PATCH] NetBSD mi_reallocarr should update errno (based on PR #499 by @devexen) --- src/alloc-posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/alloc-posix.c b/src/alloc-posix.c index 03171081..ee5babe1 100644 --- a/src/alloc-posix.c +++ b/src/alloc-posix.c @@ -103,7 +103,10 @@ void* mi_reallocarray( void* p, size_t count, size_t size ) mi_attr_noexcept { int mi_reallocarr( void* p, size_t count, size_t size ) mi_attr_noexcept { // NetBSD mi_assert(p != NULL); - if (p == NULL) return EINVAL; // should we set errno as well? + if (p == NULL) { + errno = EINVAL; + return EINVAL; + } void** op = (void**)p; void* newp = mi_reallocarray(*op, count, size); if (mi_unlikely(newp == NULL)) return errno;