]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
config: settings_add_include() - Close file descriptor if fstat() failed
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Fri, 16 May 2025 14:37:31 +0000 (16:37 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 22 May 2025 11:24:01 +0000 (11:24 +0000)
Issued by coverity resource leak error.

src/config/config-parser.c

index 389640721ecf42463b5ff3b9f6f6000ebe04c02a..5f5c514237293104dc377ca8f4f3a4cda992df41 100644 (file)
@@ -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;