Re: BUG #17632: a potential bug of memory leak

From: Japin Li <japinli(at)hotmail(dot)com>
To: 1157401338(at)qq(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17632: a potential bug of memory leak
Date: 2022-10-11 09:12:04
Message-ID: ME3P282MB1667AC5E1F8031E86782E894B6239@ME3P282MB1667.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On Tue, 11 Oct 2022 at 10:33, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 17632
> Logged by: a potential bug of memory leak
> Email address: 1157401338(at)qq(dot)com
> PostgreSQL version: 14.5
> Operating system: ubuntu20.04
> Description:
>
> Hi, I found a potential memory leak bug in the project source
> code of postgre, and I have shown the execution sequence of the program
> that
> may generate the bug on a graph,which can be access by
> https://docimg8.docs.qq.com/image/AgAACEPRUipmYhhKHB5OOoBr8hpUfqC5.png?w=2192&h=1336
> The red text illustrates the steps that generate the bug,,the file path can
> be seen in the blue framed
> section.
>
>
> Although the code shown is for version 12.12 but is still exist in current
> version
>
>
> would you can help to check if this bug is true?thank you for your effort
> and patience!

The alloc_var() release the memory before allocating memory:

static int
alloc_var(numeric *var, int ndigits)
{
digitbuf_free(var->buf); /* SEE HERE */
var->buf = digitbuf_alloc(ndigits + 1);
if (var->buf == NULL)
return -1;
var->buf[0] = 0;
var->digits = var->buf + 1;
var->ndigits = ndigits;
return 0;
}

So, I don't think it leaks.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-10-11 09:27:38 BUG #17633: Define rule on views which do insert to another relation trigger cache lookup failed error.
Previous Message Kyotaro Horiguchi 2022-10-11 06:48:24 Re: Startup process on a hot standby crashes with an error "invalid memory alloc request size 1073741824" while replaying "Standby/LOCK" records