[package] add missing rtorrent patch from #6111
[packages.git] / net / rtorrent / patches / 011-fix-bitfield-crash.patch
1 # Fix crash when trying to call d.get_bitfield on a closed download. Ticket #1825 from libtorrent.rakshasa.no.
2 Index: rtorrent/src/command_download.cc
3 ===================================================================
4 --- rtorrent/src/command_download.cc    (revision 1093)
5 +++ rtorrent/src/command_download.cc    (working copy)
6 @@ -292,6 +292,9 @@
7  
8  torrent::Object
9  retrieve_d_bitfield(core::Download* download) {
10 +  if (!download->download()->file_list()->is_open())
11 +    throw torrent::input_error("Cannot retrieve bitfield of closed download.");
12 +
13    const torrent::Bitfield* bitField = download->download()->file_list()->bitfield();
14  
15    return torrent::Object(rak::transform_hex(bitField->begin(), bitField->end()));