Skip to content

Commit

Permalink
lib-smtp: server: data command: Hold a reference to the connection wh…
Browse files Browse the repository at this point in the history
…ile 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).
  • Loading branch information
stephanbosch authored and cmouse committed Aug 7, 2018
1 parent eff8c5e commit 31ab72c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib-smtp/smtp-server-cmd-data.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 31ab72c

Please sign in to comment.