From aaa81d2dfb32ac81455d1b4fdbba343bd685f554 Mon Sep 17 00:00:00 2001 From: "geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Tue, 13 Jun 2006 11:09:40 +0000 Subject: BUILD : 1.7.14 (1047) BUGS : 464 NOTES : Added cleanup code to tools/anopesmtp to clear out used memory etc... git-svn-id: svn://svn.anope.org/anope/trunk@1047 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@771 5417fbe8-f217-4b02-8779-1006273d7864 --- src/tools/anopesmtp.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/tools') diff --git a/src/tools/anopesmtp.c b/src/tools/anopesmtp.c index 910caa3bc..59231b4ef 100644 --- a/src/tools/anopesmtp.c +++ b/src/tools/anopesmtp.c @@ -492,6 +492,35 @@ void smtp_disconnect() /*************************************************************************/ +void mail_cleanup() +{ + struct smtp_header *headers, *nexth; + struct smtp_body_line *body, *nextb; + + if (mail.from) + free(mail.from); + if (mail.to) + free(mail.to); + + headers = mail.smtp_headers; + while (headers) { + nexth = headers->next; + free(headers->header); + free(headers); + headers = nexth; + } + + body = mail.smtp_body; + while (body) { + nextb = body->next; + free(body->line); + free(body); + body = nextb; + } +} + +/*************************************************************************/ + int main(int argc, char *argv[]) { char buf[8192]; @@ -556,12 +585,16 @@ int main(int argc, char *argv[]) if (!smtp_connect(server, port)) { alog("SMTP: failed to connect to %s:%d",server, port); + mail_cleanup(); return 0; } if (!smtp_send_email()) { alog("SMTP: error during sending of mail"); + mail_cleanup(); return 0; } smtp_disconnect(); + mail_cleanup(); + return 1; } -- cgit