]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 15 Nov 2016 20:24:22 +0000 (22:24 +0200)
lib-master now guarantees that fd==0 doesn't normally happen.

src/lib/macros.h

index 593ca49d44c9125231dbc3af76e2d84acc0cfa70..36eb1584c22a15a8c92577168ac172ab8c4ccbbe 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__); \