Fix crash in metadata requests beyond available info bytes

This commit is contained in:
Matt Joiner 2014-08-22 03:42:00 +10:00
parent f4687ba28f
commit 00a4e9bc11
1 changed files with 5 additions and 1 deletions

View File

@ -91,7 +91,11 @@ func (t *torrent) MetadataPieceCount() int {
}
func (t *torrent) HaveMetadataPiece(piece int) bool {
return t.haveInfo() || t.metadataHave[piece]
if t.haveInfo() {
return (1<<14)*piece < len(t.MetaData)
} else {
return t.metadataHave[piece]
}
}
func (t *torrent) metadataSizeKnown() bool {