Commit 697cb691 authored by monotone's avatar monotone Committed by Matt Joiner

fix: copyPeersFromList may cause peerArr be empty

the `copy` function will use  the minimum of len(src) and len(dst)
parent 6ded19f1
......@@ -26,7 +26,7 @@ func (p peerSorterArr) Less(a, b int) bool {
func copyPeersFromList(target ID, peerArr peerSorterArr, peerList *list.List) peerSorterArr {
if cap(peerArr) < len(peerArr)+peerList.Len() {
newArr := make(peerSorterArr, 0, len(peerArr)+peerList.Len())
newArr := make(peerSorterArr, len(peerArr), len(peerArr)+peerList.Len())
copy(newArr, peerArr)
peerArr = newArr
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment