From: Aki Tuomi Date: Tue, 13 Jul 2021 10:41:14 +0000 (+0300) Subject: lib: data-stack - Allow errno changes when sending event X-Git-Tag: 2.3.17~238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d74cf4ca2af02e85a7ee464b81ae7ade1971f56d;p=thirdparty%2Fdovecot%2Fcore.git lib: data-stack - Allow errno changes when sending event --- diff --git a/src/lib/data-stack.c b/src/lib/data-stack.c index c0c52b6850..013e2e3f64 100644 --- a/src/lib/data-stack.c +++ b/src/lib/data-stack.c @@ -500,9 +500,17 @@ static void *t_malloc_real(size_t size, bool permanent) current_block->left -= alloc_size; if (warn) T_BEGIN { + /* sending event can cause errno changes. */ +#ifdef DEBUG + i_assert(errno == old_errno); +#else + int old_errno = errno; +#endif /* warn after allocation, so if e_debug() wants to allocate more memory we don't go to infinite loop */ data_stack_send_grow_event(alloc_size); + /* reset errno back to what it was */ + errno = old_errno; } T_END; #ifdef DEBUG memcpy(ret, &size, sizeof(size));