From: Stephan Bosch Date: Thu, 21 Jun 2018 20:55:50 +0000 (+0200) Subject: lib-smtp: server: data command: Hold a reference to the connection while handling... X-Git-Tag: 2.3.3.rc1~164 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31ab72c49438439c25befc6586b9c40a81597aee;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: server: data command: Hold a reference to the connection while handling input. 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). --- diff --git a/src/lib-smtp/smtp-server-cmd-data.c b/src/lib-smtp/smtp-server-cmd-data.c index 9916a8fdcd..067d7ec96e 100644 --- a/src/lib-smtp/smtp-server-cmd-data.c +++ b/src/lib-smtp/smtp-server-cmd-data.c @@ -279,18 +279,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; }