]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: data-stack - Allow errno changes when sending event
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 13 Jul 2021 10:41:14 +0000 (13:41 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Mon, 9 Aug 2021 15:53:32 +0000 (15:53 +0000)
src/lib/data-stack.c

index c0c52b6850f358f93a5242840eb220be805246e6..013e2e3f6472c0d5b2329a7323ad3b9654efaa27 100644 (file)
@@ -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));