]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix panic iterating webseed request that hasn't closed out yet
authorMatt Joiner <anacrolix@gmail.com>
Wed, 2 Jul 2025 05:11:34 +0000 (15:11 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 2 Jul 2025 05:12:59 +0000 (15:12 +1000)
webseed-requesting.go

index 68b8e8905374f06cf4af2b4b4065755bd977a923..0fb3d5792f80af043af952c70b3b2588edfddc8d 100644 (file)
@@ -269,6 +269,10 @@ func (cl *Client) iterCurrentWebseedRequests() iter.Seq2[webseedUniqueRequestKey
                for t := range cl.torrents {
                        for url, ws := range t.webSeeds {
                                for ar := range ws.activeRequests {
+                                       if ar.next >= ar.end {
+                                               // This request is done, so don't yield it.
+                                               continue
+                                       }
                                        off := t.requestIndexBegin(ar.next)
                                        opt := t.info.FileSegmentsIndex().LocateOffset(off)
                                        if !opt.Ok {