From: Aditya Garg Date: Fri, 20 Jun 2025 06:40:25 +0000 (+0530) Subject: imap-send: fix memory leak in case auth_cram_md5 fails X-Git-Tag: v2.51.0-rc0~99^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac4e02c5030c05d71b20127a7118b0a0fc3c1c64;p=thirdparty%2Fgit.git imap-send: fix memory leak in case auth_cram_md5 fails This patch fixes a memory leak by running free(response) in case auth_cram_md5 fails. Signed-off-by: Aditya Garg Signed-off-by: Junio C Hamano --- diff --git a/imap-send.c b/imap-send.c index 37f94a37e8..1a582c8443 100644 --- a/imap-send.c +++ b/imap-send.c @@ -905,8 +905,10 @@ static int auth_cram_md5(struct imap_store *ctx, const char *prompt) response = cram(prompt, ctx->cfg->user, ctx->cfg->pass); ret = socket_write(&ctx->imap->buf.sock, response, strlen(response)); - if (ret != strlen(response)) + if (ret != strlen(response)) { + free(response); return error("IMAP error: sending response failed"); + } free(response);