From: Karl Fleischmann Date: Fri, 16 May 2025 14:37:31 +0000 (+0200) Subject: config: settings_add_include() - Close file descriptor if fstat() failed X-Git-Tag: 2.4.2~760 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a022ae7e192b983b15aac118f35064afa34ed799;p=thirdparty%2Fdovecot%2Fcore.git config: settings_add_include() - Close file descriptor if fstat() failed Issued by coverity resource leak error. --- diff --git a/src/config/config-parser.c b/src/config/config-parser.c index 389640721e..5f5c514237 100644 --- a/src/config/config-parser.c +++ b/src/config/config-parser.c @@ -1770,8 +1770,13 @@ static int settings_add_include(struct config_parser_context *ctx, const char *p path); return -1; } - if (config_parser_add_seen_file_fd(ctx, fd, path, error_r) < 0) + if (config_parser_add_seen_file_fd(ctx, fd, path, error_r) < 0) { + /* We only get here if fstat(fd, &st) failed. As we don't + * specify what the issue is, it's safest to close the file via + * the descriptor but ignore the result. */ + i_close_fd(&fd); return -1; + } new_input = p_new(ctx->pool, struct input_stack, 1); new_input->prev = ctx->cur_input;