From eb5939e86efacfbbdab2705e3fbce52223af38a7 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 25 May 2012 15:32:20 +0200 Subject: [PATCH] SMTP-Client: catch error of us failing to allocate the new context. --- citadel/modules/smtp/serv_smtpeventclient.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index 4b6dea395..f08efde76 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -530,6 +530,8 @@ SmtpOutMsg *new_smtp_outmsg(OneQueItem *MyQItem, SmtpOutMsg * Msg; Msg = (SmtpOutMsg *) malloc(sizeof(SmtpOutMsg)); + if (Msg == NULL) + return NULL; memset(Msg, 0, sizeof(SmtpOutMsg)); Msg->n = MsgCount; @@ -567,6 +569,12 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem, SMTPC_syslog(LOG_DEBUG, "%s\n", __FUNCTION__); Msg = new_smtp_outmsg(MyQItem, MyQEntry, MsgCount); + if (Msg == NULL) { + SMTPC_syslog(LOG_DEBUG, "%s Failed to alocate message context.\n", __FUNCTION__); + if (KeepMsgText) + FreeStrBuf (&MsgText); + return; + } if (KeepMsgText) Msg->msgtext = MsgText; else Msg->msgtext = NewStrBufDup(MsgText); @@ -600,8 +608,7 @@ void smtp_try_one_queue_entry(OneQueItem *MyQItem, } else { /* No recipients? well fail then. */ - if ((Msg==NULL) || - (Msg->MyQEntry == NULL)) { + if (Msg->MyQEntry == NULL) { Msg->MyQEntry->Status = 5; StrBufPlain(Msg->MyQEntry->StatusMessage, HKEY("Invalid Recipient!")); -- 2.30.2