The newsmtp() function allocates memory for relayhost and smtphelo
but never frees them.
- relayhost: allocated via xstrdup() or ctrlvalue()
- smtphelo: allocated via ctrlvalue() or hostnamestr()
Both allocations are only used temporarily to call initsmtp(), which
copies the values it needs. So, just free() both.
Fixes: 48418b61 ("mlmmj-bounce: use send_mail directly and stop executing mlmmj-send")
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
smtphelo = ctrlvalue(ml->ctrlfd, "smtphelo");
if (smtphelo == NULL)
smtphelo = hostnamestr();
- if (initsmtp(&sockfd, relayhost, smtpport, smtphelo) != 0)
+ if (initsmtp(&sockfd, relayhost, smtpport, smtphelo) != 0) {
+ free(relayhost);
+ free(smtphelo);
return (-1);
+ }
+ free(relayhost);
+ free(smtphelo);
return (sockfd);
}