From eb0053fe48069334a759fafe380118ddbaa979fe Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 13 Jan 2011 20:38:38 +0000 Subject: [PATCH] Fix possible crashes in full allocation mode --- src/qtlibtorrent/qbtsession.cpp | 6 ++++-- src/qtlibtorrent/qbtsession.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index dbb236834..995e17444 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -2582,7 +2582,7 @@ void QBtSession::handleIPFilterError() emit ipFilterParsed(true, 0); } -entry QBtSession::generateFilePriorityResumeData(boost::intrusive_ptr t, const std::vector &fp) +entry QBtSession::generateFilePriorityResumeData(boost::intrusive_ptr &t, const std::vector &fp) { entry::dictionary_type rd; rd["file-format"] = "libtorrent resume file"; @@ -2600,6 +2600,7 @@ entry QBtSession::generateFilePriorityResumeData(boost::intrusive_ptrnum_files()); for(int i=0; inum_files(); ++i) { entry::list_type p; p.push_back(entry(0)); @@ -2616,7 +2617,8 @@ entry QBtSession::generateFilePriorityResumeData(boost::intrusive_ptrnum_pieces()); + pieces.resize(t->num_pieces()); + std::memset(&pieces[0], 0, pieces.size()); rd["pieces"] = entry(pieces); entry ret(rd); diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h index 2dc723fb2..d8b8efc97 100644 --- a/src/qtlibtorrent/qbtsession.h +++ b/src/qtlibtorrent/qbtsession.h @@ -167,7 +167,7 @@ private: void loadTorrentSettings(QTorrentHandle h); void loadTorrentTempData(QTorrentHandle h, QString savePath, bool magnet); libtorrent::add_torrent_params initializeAddTorrentParams(QString hash); - libtorrent::entry generateFilePriorityResumeData(boost::intrusive_ptr t, const std::vector &fp); + libtorrent::entry generateFilePriorityResumeData(boost::intrusive_ptr &t, const std::vector &fp); private slots: void addTorrentsFromScanFolder(QStringList&);