Skip to content

Commit 8f4a369

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 8caf9fe commit 8f4a369

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
@@ -1573,7 +1573,8 @@ RestoreSnapshot(char *start_address)
15731573
/* Copy SubXIDs, if present. */
15741574
if (serialized_snapshot->subxcnt > 0)
15751575
{
1576-
snapshot->subxip = snapshot->xip + serialized_snapshot->xcnt;
1576+
snapshot->subxip = ((TransactionId *) (snapshot + 1)) +
1577+
serialized_snapshot->xcnt;
15771578
memcpy(snapshot->subxip, serialized_xids + serialized_snapshot->xcnt,
15781579
serialized_snapshot->subxcnt * sizeof(TransactionId));
15791580
}

0 commit comments

Comments
 (0)