From 0527c1bdf5d7208a2bb83a27f9e458f68e798721 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 5 Dec 2017 21:51:13 +0800 Subject: [PATCH] apps/smtp: Avoid NULL pointer dereference in smtp_send_body_data_handler Move the code to have NULL test before dereference. Signed-off-by: Axel Lin Signed-off-by: goldsimon --- src/apps/smtp/smtp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apps/smtp/smtp.c b/src/apps/smtp/smtp.c index 199b07a6..848d47db 100644 --- a/src/apps/smtp/smtp.c +++ b/src/apps/smtp/smtp.c @@ -1496,9 +1496,10 @@ smtp_send_mail_bodycback(const char *from, const char* to, const char* subject, static void smtp_send_body_data_handler(struct smtp_session *s, struct altcp_pcb *pcb) { - struct smtp_bodydh_state *bdh = s->bodydh; + struct smtp_bodydh_state *bdh; int res = 0, ret; LWIP_ASSERT("s != NULL", s != NULL); + bdh = s->bodydh; LWIP_ASSERT("bodydh != NULL", bdh != NULL); /* resume any leftovers from prior memory constraints */