From 0b21cb78aa717e91fbed9efc1ffbfe770bd8c37b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Tue, 1 Nov 2022 14:45:15 +0000 Subject: [PATCH] Try to fix a panic in the sync API PDU stream --- syncapi/streams/stream_pdu.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go index 90f401481..81f32301f 100644 --- a/syncapi/streams/stream_pdu.go +++ b/syncapi/streams/stream_pdu.go @@ -321,10 +321,14 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse( ) if len(delta.StateEvents) > 0 { - updateLatestPosition(delta.StateEvents[len(delta.StateEvents)-1].EventID()) + if last := delta.StateEvents[len(delta.StateEvents)-1]; last != nil { + updateLatestPosition(last.EventID()) + } } if len(events) > 0 { - updateLatestPosition(events[len(events)-1].EventID()) + if last := events[len(events)-1]; last != nil { + updateLatestPosition(last.EventID()) + } } switch delta.Membership {