aboutsummaryrefslogtreecommitdiff
path: root/syncapi
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-11-01 14:45:15 +0000
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-11-01 14:45:15 +0000
commit0b21cb78aa717e91fbed9efc1ffbfe770bd8c37b (patch)
treec44b9b8e9f61d95dc536bcf091be47da414438d0 /syncapi
parent7bd663193571b5994222c3f7399601eb64d853bd (diff)
Try to fix a panic in the sync API PDU stream
Diffstat (limited to 'syncapi')
-rw-r--r--syncapi/streams/stream_pdu.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go
index 90f40148..81f32301 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 {