From: Baptiste Daroussin Date: Tue, 2 Nov 2021 14:22:14 +0000 (+0100) Subject: cleanup: use dprintf earlier to avoid temporary memory allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faa3998f810557bb7cef3b2c53e950fde4ab6052;p=thirdparty%2Fmlmmj.git cleanup: use dprintf earlier to avoid temporary memory allocation --- diff --git a/src/send_digest.c b/src/send_digest.c index ef8d5cec..4c38d696 100644 --- a/src/send_digest.c +++ b/src/send_digest.c @@ -237,7 +237,7 @@ static void finish_thread_list(thread_list_state * s) int send_digest(struct mlmmj_list *list, int firstindex, int lastindex, int issue, const char *addr, const char *mlmmjsend) { - int i, fd, archivefd, status, hdrfd; + int i, fd, archivefd, status, hdrfd, r; size_t len; text * txt; char buf[100]; @@ -361,20 +361,16 @@ fallback_subject: myfree(tmp); } - tmp = concatstr(10, "From: ", list->name, list->delim, "help@", list->fqdn, + r = dprintf(fd, "From: %s%shelp@%s" "\nMIME-Version: 1.0" "\nContent-Type: multipart/" DIGESTMIMETYPE "; " - "boundary=", boundary, - "\nSubject: ", subject, - "\n"); - + "boundary=%s" + "\nSubject: %s\n", + list->name, list->delim, list->fqdn, boundary, subject); myfree(subject); - if (dprintf(fd, "%s", tmp) < 0) { - myfree(tmp); + if (r < 0) goto errdighdrs; - } - myfree(tmp); if(hdrfd >= 0 && dumpfd2fd(hdrfd, fd) < 0) { goto errdighdrs;