[PATCH] Fix Potential Memory Leak in pg_amcheck Code

From: Saladin <312199339(at)qq(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH] Fix Potential Memory Leak in pg_amcheck Code
Date: 2025-02-07 07:04:45
Message-ID: tencent_F34922C91C41E76C734773E767C9FBDB9906@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear pgsql-hackers,

While reviewing the code of&nbsp;pg_amcheck, I discovered a potential issue that could lead to a memory leak. Specifically, there is a missing&nbsp;PQclear(result)&nbsp;call before the database connection is disconnected, which could leave the query result unfreed.

To resolve this, I have created a patch that ensures&nbsp;PQclear(result)&nbsp;is called prior to the&nbsp;disconnectDatabase(conn)&nbsp;function. This small change ensures proper memory management by cleaning up the query result before closing the connection.

Please find the patch attached for your review.

I would appreciate any feedback or suggestions on this fix. If it looks good, I would be happy to proceed with any necessary steps to contribute it to the project.

Thank you for your time and consideration.

--

Best regards,
JiaoShuntian,
Highgo Software.

Attachment Content-Type Size
0001-pg_amcheck-prevent-potential-memory-leak.patch application/octet-stream 821 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-02-07 07:16:54 Re: Avoid updating inactive_since for invalid replication slots
Previous Message Michael Paquier 2025-02-07 06:47:02 Re: Fix for a crash caused by triggers in cross-partition updates