Prevent OOB error in addRoomDeltaToResponse

This commit is contained in:
Neil Alexander 2020-01-22 18:04:58 +00:00
parent 86dc91846b
commit 6cea9e8e67

View file

@ -829,10 +829,12 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse(
// Retrieve the backward topology position, i.e. the position of the
// oldest event in the room's topology.
var backwardTopologyPos types.StreamPosition
if len(recentStreamEvents) > 0 {
backwardTopologyPos, err = d.topology.selectPositionInTopology(ctx, recentStreamEvents[0].EventID())
if err != nil {
return err
}
}
if backwardTopologyPos-1 <= 0 {
backwardTopologyPos = types.StreamPosition(1)
} else {