Skip to content

Commit 4f9f495

Browse files
committed
Fix crash bug in RestoreSnapshot.
If serialized_snapshot->subxcnt > 0 and serialized_snapshot->xcnt == 0, the old coding would do the wrong thing and crash. This can happen on standby servers. Report by Andreas Seltenreich. Patch by Thomas Munro, reviewed by Amit Kapila and tested by Andreas Seltenreich.
1 parent 10c0558 commit 4f9f495

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/backend/utils/time/snapmgr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,8 @@ RestoreSnapshot(char *start_address)
20162016
/* Copy SubXIDs, if present. */
20172017
if (serialized_snapshot->subxcnt > 0)
20182018
{
2019-
snapshot->subxip = snapshot->xip + serialized_snapshot->xcnt;
2019+
snapshot->subxip = ((TransactionId *) (snapshot + 1)) +
2020+
serialized_snapshot->xcnt;
20202021
memcpy(snapshot->subxip, serialized_xids + serialized_snapshot->xcnt,
20212022
serialized_snapshot->subxcnt * sizeof(TransactionId));
20222023
}

0 commit comments

Comments
 (0)