]> git.ipfire.org Git - thirdparty/git.git/commitdiff
imap-send: fix memory leak in case auth_cram_md5 fails
authorAditya Garg <gargaditya08@live.com>
Fri, 20 Jun 2025 06:40:25 +0000 (12:10 +0530)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Jun 2025 15:11:16 +0000 (08:11 -0700)
This patch fixes a memory leak by running free(response) in case
auth_cram_md5 fails.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c

index 37f94a37e80aaf74d75fc8a1e2e6e54baf1af66f..1a582c844395e4abec8eaddcf24e15043079828c 100644 (file)
@@ -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);