]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: server: data command: Hold a reference to the connection while handling...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 21 Jun 2018 20:55:50 +0000 (22:55 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 26 Jun 2018 19:11:55 +0000 (19:11 +0000)
Makes sure connection object remains available while command is handled. Fixes a
valgrind error reported for accessing the connection object after it is freed,
which happens for the destroy debug message of the command (even when debugging
is not enabled).

src/lib-smtp/smtp-server-cmd-data.c

index c74a61a3ff02099358516386ebfb909960066f31..f2ed0609d1cb8c2db0db8a0aa90d383075959c47 100644 (file)
@@ -296,18 +296,21 @@ static int cmd_data_do_handle_input(struct smtp_server_cmd_ctx *cmd)
 
 static int cmd_data_handle_input(struct smtp_server_cmd_ctx *cmd)
 {
+       struct smtp_server_connection *conn = cmd->conn;
        struct smtp_server_command *command = cmd->cmd;
        int ret;
 
        if (!smtp_server_cmd_data_check_size(cmd))
                return -1;
 
+       smtp_server_connection_ref(conn);
        smtp_server_command_ref(command);
 
        /* continue reading from client */
        ret = cmd_data_do_handle_input(cmd);
        
        smtp_server_command_unref(&command);
+       smtp_server_connection_unref(&conn);
 
        return ret;
 }