From: Michael S. Tsirkin Date: Wed, 7 Jan 2026 08:42:53 +0000 (-0500) Subject: subscriberfuncs: fix memory leak in autosubscribe_sender X-Git-Tag: RELEASE_1_7_0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cc2355eab0fe043df2bf63452f1fbb9d37abc87;p=thirdparty%2Fmlmmj.git subscriberfuncs: fix memory leak in autosubscribe_sender The readhdrs structure allocated by scan_headers() was never freed, causing a memory leak on every call to autosubscribe_sender(). Add free_mailhdrs() calls to all return paths. Fixes: ac7f764 ("autosubscribe: new feature") --- diff --git a/src/subscriberfuncs.c b/src/subscriberfuncs.c index 791ae746..618e3921 100644 --- a/src/subscriberfuncs.c +++ b/src/subscriberfuncs.c @@ -736,18 +736,23 @@ autosubscribe_sender(struct ml *ml, int mailfd, enum subtype typesub) FILE *f = fdopen(mailfd, "r"); scan_headers(f, readhdrs, NULL, NULL); fclose(f); - if (readhdrs[0].valuecount == 0) + if (readhdrs[0].valuecount == 0) { + free_mailhdrs(readhdrs); return; + } find_email_adr(readhdrs[0].values[0], &from); if (tll_length(from) == 0) { tll_free(from); + free_mailhdrs(readhdrs); return; } if (strchr(tll_front(from), '@') == NULL) { tll_free_and_free(from, free); + free_mailhdrs(readhdrs); return; } subscribe_type(ml->fd, tll_front(from), typesub); tll_free_and_free(from, free); + free_mailhdrs(readhdrs); }