Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4b82ed6

Browse files
author
Amit Kapila
committed
Fix dangling pointer reference in stream_cleanup_files.
We can't access the entry after it is removed from dynahash. Author: Peter Smith Discussion: https://postgr.es/m/CAHut+Ps-pL++f6CJwPx2+vUqXuew=Xt-9Bi-6kCyxn+Fwi2M7w@mail.gmail.com
1 parent a5f002a commit 4b82ed6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/replication/logical/worker.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,14 +2740,14 @@ stream_cleanup_files(Oid subid, TransactionId xid)
27402740
{
27412741
char path[MAXPGPATH];
27422742
StreamXidHash *ent;
2743+
bool found = false;
27432744

2744-
/* Remove the xid entry from the stream xid hash */
2745+
/* By this time we must have created the transaction entry */
27452746
ent = (StreamXidHash *) hash_search(xidhash,
27462747
(void *) &xid,
2747-
HASH_REMOVE,
2748-
NULL);
2749-
/* By this time we must have created the transaction entry */
2750-
Assert(ent != NULL);
2748+
HASH_FIND,
2749+
&found);
2750+
Assert(found);
27512751

27522752
/* Delete the change file and release the stream fileset memory */
27532753
changes_filename(path, subid, xid);
@@ -2763,6 +2763,9 @@ stream_cleanup_files(Oid subid, TransactionId xid)
27632763
pfree(ent->subxact_fileset);
27642764
ent->subxact_fileset = NULL;
27652765
}
2766+
2767+
/* Remove the xid entry from the stream xid hash */
2768+
hash_search(xidhash, (void *) &xid, HASH_REMOVE, NULL);
27662769
}
27672770

27682771
/*

0 commit comments

Comments
 (0)