apps/smtp: Fix memory leak in smtp_send_mail_alloced error paths

Call smtp_free_struct(s) in all smtp_send_mail_alloced error paths to ensure
no memory leak.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dirk Ziegelmeier <dirk@ziegelmeier.net>
This commit is contained in:
Axel Lin 2017-05-11 16:31:39 +08:00 committed by Dirk Ziegelmeier
parent ec9096be40
commit 9dee346000

View File

@ -483,20 +483,24 @@ smtp_send_mail_alloced(struct smtp_session *s)
* - only 7-bit ASCII is allowed
*/
if (smtp_verify(s->to, s->to_len, 0) != ERR_OK) {
return ERR_ARG;
err = ERR_ARG;
goto leave;
}
if (smtp_verify(s->from, s->from_len, 0) != ERR_OK) {
return ERR_ARG;
err = ERR_ARG;
goto leave;
}
if (smtp_verify(s->subject, s->subject_len, 0) != ERR_OK) {
return ERR_ARG;
err = ERR_ARG;
goto leave;
}
#if SMTP_BODYDH
if (s->bodydh == NULL)
#endif /* SMTP_BODYDH */
{
if (smtp_verify(s->body, s->body_len, 0) != ERR_OK) {
return ERR_ARG;
err = ERR_ARG;
goto leave;
}
}
#endif /* SMTP_CHECK_DATA */