Browse Source

- Make sure the torrent file is valid before loading it

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
a7820e5f08
  1. 2
      src/bittorrent.cpp
  2. 2
      src/torrentadditiondlg.h

2
src/bittorrent.cpp

@ -857,6 +857,8 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
try { try {
// Getting torrent file informations // Getting torrent file informations
t = new torrent_info(file.toLocal8Bit().data()); t = new torrent_info(file.toLocal8Bit().data());
if(!t->is_valid())
throw std::exception();
} catch(std::exception&) { } catch(std::exception&) {
if(!from_url.isNull()) { if(!from_url.isNull()) {
addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red")); addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));

2
src/torrentadditiondlg.h

@ -158,6 +158,8 @@ public:
// Getting torrent file informations // Getting torrent file informations
try { try {
t = new torrent_info(filePath.toLocal8Bit().data()); t = new torrent_info(filePath.toLocal8Bit().data());
if(!t->is_valid())
throw std::exception();
} catch(std::exception&) { } catch(std::exception&) {
qDebug("Caught error loading torrent"); qDebug("Caught error loading torrent");
if(!from_url.isNull()){ if(!from_url.isNull()){

Loading…
Cancel
Save