Re: [PATCH 1/2] imap-send: fix bug causing cfg->folder being set to NULL
- From
Aditya Garg <gargaditya08@live.com>
- Date
- May 22, 2025, 19:40 UTC
- Message-ID
- <PN3PR01MB9597FEFB450A45DA3E9E0716B899A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
- In-Reply-To
- <CAPig+cQkrwy2GBNh7OdBAzWnuSo7mVH1XFUyuB7LzJ4cMf10MQ@mail.gmail.com>
On 23-05-2025 01:02 am, Eric Sunshine wrote:
Show 28 quoted lines
> On Thu, May 22, 2025 at 3:30 PM Aditya Garg <gargaditya08@live.com> wrote:
>>> Not sure about server_fill_credential(), but I think this is also
>>> a potential memory leak
>>>
>>> static int auth_cram_md5(struct imap_store *ctx, const char *prompt)
>>> {
>>> int ret;
>>> char *response;
>>>
>>> response = cram(prompt, ctx->cfg->user, ctx->cfg->pass);
>>>
>>> ret = socket_write(&ctx->imap->buf.sock, response, strlen(response));
>>> if (ret != strlen(response))
>>> + free(response); // fix for the leak
>>> return error("IMAP error: sending response failed");
>>>
>>> free(response);
>>>
>>> return 0;
>>> }
>>
>> So this change leads to:
>>
>> imap-send.c:990:2: error: code will never be executed [-Werror,-Wunreachable-code]
>> free(response);
>> ^~~~
>
> Is that because you forgot the curly braces around the `if` body?Yes I did forget. Side effects of writing python for a few days ;)
Not working on the port leaks rn though, the logic seems different from the strings. And again, feel free to treat rest as a bug report.