From ceaf5a2360439bc5fd8de3aec9cfd11c99bb58c3 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 29 Jan 2018 18:21:37 +1100 Subject: [PATCH] Add some sanity checks to priorities extracted from Torrent.pendingPieces --- torrent.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/torrent.go b/torrent.go index 1eb237e8..41937517 100644 --- a/torrent.go +++ b/torrent.go @@ -999,7 +999,14 @@ func (t *Torrent) piecePriority(piece int) piecePriority { if !ok { return PiecePriorityNone } - return piecePriority(-prio) + if prio > 0 { + panic(prio) + } + ret := piecePriority(-prio) + if ret == PiecePriorityNone { + panic(piece) + } + return ret } func (t *Torrent) pendRequest(req request) {