Skip to content

Commit

Permalink
lib-smtp: smtp-client-command - Create local variable for "was_sent" …
Browse files Browse the repository at this point in the history
…command status.

The condition is amended with (state < SMTP_CLIENT_COMMAND_STATE_FINISHED),
because that part is now checked after the intiialization of this variable
(causing the function to exit). It is important that the content of this
variable makes sense immediately (for future changes), rather than only after
the if statement that checks the added condition.
  • Loading branch information
stephanbosch committed Feb 19, 2019
1 parent 1c2e805 commit 1a46709
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib-smtp/smtp-client-command.c
Expand Up @@ -177,6 +177,9 @@ void smtp_client_command_abort(struct smtp_client_command **_cmd)
bool was_locked =
(state >= SMTP_CLIENT_COMMAND_STATE_SUBMITTED) &&
(cmd->locked || cmd->plug);
bool was_sent =
(!disconnected && state > SMTP_CLIENT_COMMAND_STATE_SUBMITTED &&
state < SMTP_CLIENT_COMMAND_STATE_FINISHED);

*_cmd = NULL;

Expand All @@ -186,7 +189,7 @@ void smtp_client_command_abort(struct smtp_client_command **_cmd)
state >= SMTP_CLIENT_COMMAND_STATE_FINISHED)
return;

if (disconnected || state <= SMTP_CLIENT_COMMAND_STATE_SUBMITTED) {
if (!was_sent) {
e_debug(cmd->event, "Abort");
cmd->state = SMTP_CLIENT_COMMAND_STATE_ABORTED;
} else {
Expand Down

0 comments on commit 1a46709

Please sign in to comment.