mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Fix use-after-free issue in slot synchronization.
Author: Shlok Kyal <shlok.kyal.oss@gmail.com> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Backpatch-through: 18, where it was introduced Discussion: https://postgr.es/m/CANhcyEXMrcEdzj-RNGJam0nJHM4y+ttdWsgUCFmXciM7BNKc7A@mail.gmail.com
This commit is contained in:
@@ -1476,7 +1476,6 @@ ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len)
|
||||
*/
|
||||
wrconn = walrcv_connect(PrimaryConnInfo, false, false, false,
|
||||
app_name.data, &err);
|
||||
pfree(app_name.data);
|
||||
|
||||
if (!wrconn)
|
||||
ereport(ERROR,
|
||||
@@ -1484,6 +1483,8 @@ ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len)
|
||||
errmsg("synchronization worker \"%s\" could not connect to the primary server: %s",
|
||||
app_name.data, err));
|
||||
|
||||
pfree(app_name.data);
|
||||
|
||||
/*
|
||||
* Register the disconnection callback.
|
||||
*
|
||||
|
@@ -921,7 +921,6 @@ pg_sync_replication_slots(PG_FUNCTION_ARGS)
|
||||
/* Connect to the primary server. */
|
||||
wrconn = walrcv_connect(PrimaryConnInfo, false, false, false,
|
||||
app_name.data, &err);
|
||||
pfree(app_name.data);
|
||||
|
||||
if (!wrconn)
|
||||
ereport(ERROR,
|
||||
@@ -929,6 +928,8 @@ pg_sync_replication_slots(PG_FUNCTION_ARGS)
|
||||
errmsg("synchronization worker \"%s\" could not connect to the primary server: %s",
|
||||
app_name.data, err));
|
||||
|
||||
pfree(app_name.data);
|
||||
|
||||
SyncReplicationSlots(wrconn);
|
||||
|
||||
walrcv_disconnect(wrconn);
|
||||
|
Reference in New Issue
Block a user