1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 07:18:08 +00:00

Use out of range value when the number of files can't be determined

Trying to get the number of files of a torrent with no metadata causes
a crash. Prevent this by first checking if the metadata is available.
If the number of files can't be determined, -1 will be returned.

Closes #2522.
This commit is contained in:
Gabriele 2015-02-13 16:04:59 +01:00
parent 0cab34aa11
commit 52c8a570e1

View File

@ -243,6 +243,8 @@ bool QTorrentHandle::has_filtered_pieces() const
int QTorrentHandle::num_files() const int QTorrentHandle::num_files() const
{ {
if (!has_metadata())
return -1;
#if LIBTORRENT_VERSION_NUM < 10000 #if LIBTORRENT_VERSION_NUM < 10000
return torrent_handle::get_torrent_info().num_files(); return torrent_handle::get_torrent_info().num_files();
#else #else