mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-19 12:53:09 -06:00
Prevent OOB error in addRoomDeltaToResponse
This commit is contained in:
parent
86dc91846b
commit
6cea9e8e67
|
|
@ -829,9 +829,11 @@ func (d *SyncServerDatasource) addRoomDeltaToResponse(
|
||||||
// Retrieve the backward topology position, i.e. the position of the
|
// Retrieve the backward topology position, i.e. the position of the
|
||||||
// oldest event in the room's topology.
|
// oldest event in the room's topology.
|
||||||
var backwardTopologyPos types.StreamPosition
|
var backwardTopologyPos types.StreamPosition
|
||||||
backwardTopologyPos, err = d.topology.selectPositionInTopology(ctx, recentStreamEvents[0].EventID())
|
if len(recentStreamEvents) > 0 {
|
||||||
if err != nil {
|
backwardTopologyPos, err = d.topology.selectPositionInTopology(ctx, recentStreamEvents[0].EventID())
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if backwardTopologyPos-1 <= 0 {
|
if backwardTopologyPos-1 <= 0 {
|
||||||
backwardTopologyPos = types.StreamPosition(1)
|
backwardTopologyPos = types.StreamPosition(1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue