From ba5172150aeb4b9019b36625fc56d5163f9e1c7c Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Wed, 19 Jan 2011 00:20:26 +0000 Subject: [PATCH] (trunk libT) #3912 "tr_torrentGetMetadataPercent() may return NaN" -- fixed. --- libtransmission/torrent-magnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtransmission/torrent-magnet.c b/libtransmission/torrent-magnet.c index f8463651c..16d8b6071 100644 --- a/libtransmission/torrent-magnet.c +++ b/libtransmission/torrent-magnet.c @@ -358,7 +358,7 @@ tr_torrentGetMetadataPercent( const tr_torrent * tor ) ret = 1.0; else { const struct tr_incomplete_metadata * m = tor->incompleteMetadata; - if( m == NULL ) + if( !m || !m->pieceCount ) ret = 0.0; else ret = (m->pieceCount - m->piecesNeededCount) / (double)m->pieceCount;