]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
prepstdreply: fix resource leaks in error paths
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 12 Jan 2026 15:37:43 +0000 (10:37 -0500)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 13 Feb 2026 13:36:44 +0000 (14:36 +0100)
Use close_text() instead of free() when cleaning up txt in error paths.
The txt parameter is a fully initialized text structure from open_text(),
so it needs proper cleanup via close_text() to free all internal resources.

Also add missing close_text() call when prepstdreply_to() fails.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
src/prepstdreply.c

index 0ff338b300a9c4050cc98df64996a021b96ffc9f..7ef77ffa3dcd766647c0d70635a9c3dfce101179 100644 (file)
@@ -1778,13 +1778,14 @@ char *prepstdreply(text *txt, struct ml *ml, const char *from, const char *to, c
        if(outfd < 0) {
                log_error(LOG_ARGS, "Could not open std mail %s", retstr);
                free(retstr);
-               free(txt);
+               close_text(txt);
                return NULL;
        }
        if (!prepstdreply_to(txt, ml, from, to, replyto, outfd, NULL)) {
                close(outfd);
                unlink(retstr);
                free(retstr);
+               close_text(txt);
                return (NULL);
        }
        return (retstr);