mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 17:23:09 -06:00
🔢 Fix index out of range
This commit is contained in:
parent
51b119107c
commit
3267ba827f
|
|
@ -166,10 +166,16 @@ func (d *Database) AddState(
|
|||
return 0, fmt.Errorf("d.StateBlockTable.BulkSelectStateBlockEntries: %w", berr)
|
||||
}
|
||||
for i := len(state) - 1; i >= 0; i-- {
|
||||
for _, events := range blocks {
|
||||
for j := 0; j < len(blocks) && i < len(state); j++ {
|
||||
events := blocks[j]
|
||||
for _, event := range events {
|
||||
if state[i].EventNID == event {
|
||||
state = append(state[:i], state[i+1:]...)
|
||||
if i+1 < len(state) {
|
||||
state = append(state[:i], state[i+1:]...)
|
||||
} else {
|
||||
state = state[:i]
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue