Closed hydaizd closed 1 year ago
版本:v4.12.0 util/list.go文件中,在Push方法中调用p.Pre.InsertAfter(item),p.Pre为空指针,导致在调用InsertAfter方法时,代码行:insert.list = item.list,item空指针导致程序异常退出。
func (p *List[T]) Push(item *ListItem[T]) { if item.list != nil { panic("item already in list") } if p.Length == 0 { p.Next = &p.ListItem p.Pre = &p.ListItem p.ListItem.list = p } p.Pre.InsertAfter(item) } func (item *ListItem[T]) InsertAfter(insert *ListItem[T]) { if insert.list != nil { panic("item already in list") } insert.list = item.list insert.Next = item.Next insert.Pre = item item.Next.Pre = insert item.Next = insert item.list.Length++ }
ok
理论上pre为空的话p.Length == 0也应该成立,方便打个断点看一下吗?
当时看的时候p.Length的值为24,不是0,等复现再截图发上来给你看下
有复现路径吗?最好我能本地复现就好弄了
重现了的话我把整个调用路径记下来,之前是在调用Recycle方法里面进入的。
👌,多谢
安排在4.5.3 中解决
版本:v4.12.0 util/list.go文件中,在Push方法中调用p.Pre.InsertAfter(item),p.Pre为空指针,导致在调用InsertAfter方法时,代码行:insert.list = item.list,item空指针导致程序异常退出。