Re: Report a potential memory leak in describeOneTableDetails()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: wliang(at)stu(dot)xidian(dot)edu(dot)cn
Cc: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Report a potential memory leak in describeOneTableDetails()
Date: 2022-02-15 16:36:48
Message-ID: 3052377.1644943008@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

wliang(at)stu(dot)xidian(dot)edu(dot)cn writes:
> I find a potential memory leak in PostgresSQL 14.1, which is in the function describeOneTableDetails (./src/bin/psql/describe.c).

Do you want to submit a patch? The amount of memory involved here isn't
much, but since psql is a potentially long-running program, it seems worth
the trouble to be careful.

I think the best fix might be to drop these strdup's altogether, and
instead postpone freeing the PGresult to the end of the function, so
that we can just use the pointers returned by PQgetvalue.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2022-02-15 16:47:56 Re: BUG #17385: "RESET transaction_isolation" inside serializable transaction causes Assert at the transaction end
Previous Message Tom Lane 2022-02-15 16:33:26 Re: Report a potential memory leak in setup_config()