[PATCH v16 02/10] imap-send: fix memory leak in case auth_cram_md5 fails
- From
Aditya Garg <gargaditya08@live.com>
- Date
- Jun 9, 2025, 07:20 UTC
- Message-ID
- <PN3PR01MB95976D757945B4984A73E406B86BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
- In-Reply-To
- <PN3PR01MB95976572C3B14C983802ECC1B86BA@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
This patch fixes a memory leak by running free(response) in case auth_cram_md5 fails.
Signed-off-by: Aditya Garg <gargaditya08@live.com> --- imap-send.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
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);
-- 2.49.0