Fix use of variable after pfree

From: Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Fix use of variable after pfree
Date: 2025-09-02 07:32:23
Message-ID: CANhcyEXMrcEdzj-RNGJam0nJHM4y+ttdWsgUCFmXciM7BNKc7A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While going through the code of the slot sync worker, I found that in
functions ReplSlotSyncWorkerMain and pg_sync_replication_slots the
variable app_name.data is being used after it is freed.

We can get logs as following:
2025-09-02 12:26:48.520 IST [3908359] ERROR: synchronization worker
"" could not connect to the primary server: connection to server at
"localhost" (127.0.0.1), port 5432 failed: Connection refused
Is the server running on that host and accepting TCP/IP connections?

I have moved the pfree(app_data.name) after its usage.

This change was introduced in PG_18.
The patch applies in the HEAD and REL_18_STABLE branches.

Thanks,
Shlok Kyal

Attachment Content-Type Size
v1-0001-Fix-use-of-variable-after-pfree.patch application/octet-stream 2.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo Nagata 2025-09-02 07:33:41 Re: Allow to collect statistics on virtual generated columns
Previous Message Michael Paquier 2025-09-02 07:29:16 Re: Refactoring: Use soft error reporting for *_opt_error functions