1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

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
This commit is contained in:
Amit Kapila
2021-03-23 09:43:33 +05:30
parent a5f002ad9a
commit 4b82ed6eca

View File

@ -2740,14 +2740,14 @@ stream_cleanup_files(Oid subid, TransactionId xid)
{
char path[MAXPGPATH];
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,
(void *) &xid,
HASH_REMOVE,
NULL);
/* By this time we must have created the transaction entry */
Assert(ent != NULL);
HASH_FIND,
&found);
Assert(found);
/* Delete the change file and release the stream fileset memory */
changes_filename(path, subid, xid);
@ -2763,6 +2763,9 @@ stream_cleanup_files(Oid subid, TransactionId xid)
pfree(ent->subxact_fileset);
ent->subxact_fileset = NULL;
}
/* Remove the xid entry from the stream xid hash */
hash_search(xidhash, (void *) &xid, HASH_REMOVE, NULL);
}
/*