Skip to content

Conversation

@Bistutu
Copy link

@Bistutu Bistutu commented Oct 20, 2024

修复内容

sortedlist 包的 appendValue 函数中,修正了 All 方法初始化迭代器时将 nil 作为第一个元素添加到数据切片中,导致后续类型断言 iter.Value().(Segment) 时发生 panic 的问题。bug 来源于相关issue:#3

具体修改

将原先的条件判断:

if t.key >= lower && t.key <= upper {
    values = append(values, t.value)
}

修改为:

if t.key >= lower && t.key <= upper && t.value != nil {
    values = append(values, t.value)
}

确保只有非 nil 的值才会被添加到迭代器的数据切片中,从而避免类型断言时的 panic。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant