From: Timo Sirainen Date: Mon, 14 Nov 2016 13:54:37 +0000 (+0100) Subject: lib: Assert-crash in i_close_fd() if fd == 0 X-Git-Tag: 2.2.27~173 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2135342de3679ddbf91448c198d36e2140c75f6d;p=thirdparty%2Fdovecot%2Fcore.git lib: Assert-crash in i_close_fd() if fd == 0 lib-master now guarantees that fd==0 doesn't normally happen. --- diff --git a/src/lib/macros.h b/src/lib/macros.h index 593ca49d44..36eb1584c2 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -208,8 +208,11 @@ #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__); \