]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Assert-crash in i_close_fd() if fd == 0
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 14 Nov 2016 13:54:37 +0000 (14:54 +0100)
committerGitLab <gitlab@git.dovecot.net>
Mon, 14 Nov 2016 17:37:00 +0000 (19:37 +0200)
lib-master now guarantees that fd==0 doesn't normally happen.

src/lib/macros.h

index eab0da1f0494ecd08a49a7ec5e84a3a2f8b0ba88..4eff76eb08eec506905e4242442d85eba5fd7e69 100644 (file)
 
 #endif
 
+/* Close the fd and set it to -1. This assert-crashes if fd == 0. Normally
+   this would happen only if an uninitialized fd is attempted to be closed,
+   which is a bug. */
 #define i_close_fd(fd) STMT_START {  \
-       i_assert(*fd != -1); \
+       i_assert(*fd > 0); \
        if (unlikely(close_keep_errno(fd) < 0)) \
                i_error("close(%d[%s:%d]) failed: %m", \
                        *(fd), __FILE__, __LINE__); \