apps/smtp: Fix memory leak if SMTP_BODYDH_MALLOC fails

Need to free s before return error.

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-10 16:42:09 +08:00 committed by Dirk Ziegelmeier
parent 5bbe190b3b
commit ae210967f2

View File

@ -1447,6 +1447,7 @@ smtp_send_mail_bodycback(const char *from, const char* to, const char* subject,
memset(s, 0, sizeof(struct smtp_session));
s->bodydh = (struct smtp_bodydh_state*)SMTP_BODYDH_MALLOC(sizeof(struct smtp_bodydh_state));
if (s->bodydh == NULL) {
SMTP_STATE_FREE(s);
return ERR_MEM;
}
memset(s->bodydh, 0, sizeof(struct smtp_bodydh));