Commit 4b82ed6e authored by Amit Kapila's avatar Amit Kapila

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
parent a5f002ad
...@@ -2740,14 +2740,14 @@ stream_cleanup_files(Oid subid, TransactionId xid) ...@@ -2740,14 +2740,14 @@ stream_cleanup_files(Oid subid, TransactionId xid)
{ {
char path[MAXPGPATH]; char path[MAXPGPATH];
StreamXidHash *ent; StreamXidHash *ent;
bool found = false;
/* Remove the xid entry from the stream xid hash */ /* By this time we must have created the transaction entry */
ent = (StreamXidHash *) hash_search(xidhash, ent = (StreamXidHash *) hash_search(xidhash,
(void *) &xid, (void *) &xid,
HASH_REMOVE, HASH_FIND,
NULL); &found);
/* By this time we must have created the transaction entry */ Assert(found);
Assert(ent != NULL);
/* Delete the change file and release the stream fileset memory */ /* Delete the change file and release the stream fileset memory */
changes_filename(path, subid, xid); changes_filename(path, subid, xid);
...@@ -2763,6 +2763,9 @@ stream_cleanup_files(Oid subid, TransactionId xid) ...@@ -2763,6 +2763,9 @@ stream_cleanup_files(Oid subid, TransactionId xid)
pfree(ent->subxact_fileset); pfree(ent->subxact_fileset);
ent->subxact_fileset = NULL; ent->subxact_fileset = NULL;
} }
/* Remove the xid entry from the stream xid hash */
hash_search(xidhash, (void *) &xid, HASH_REMOVE, NULL);
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment