mirror of
https://github.com/transmission/transmission
synced 2025-03-15 16:29:34 +00:00
fixup: crash after completing magnet link metainfo (#2215)
This commit is contained in:
parent
dbd9130d9d
commit
68e3820ed1
4 changed files with 9 additions and 6 deletions
|
@ -274,6 +274,10 @@ tr_cache* tr_cacheNew(int64_t max_bytes)
|
|||
|
||||
void tr_cacheFree(tr_cache* cache)
|
||||
{
|
||||
// FIXME(ckerr): this assertion isn't _always_ going to be true,
|
||||
// e.g. if writing to disk failed due to disk full / permission error etc
|
||||
// then there is still going to be data sitting in the cache on shutdown.
|
||||
// Make this assertion smarter or remove it.
|
||||
TR_ASSERT(tr_ptrArrayEmpty(&cache->blocks));
|
||||
|
||||
tr_ptrArrayDestruct(&cache->blocks, nullptr);
|
||||
|
|
|
@ -305,9 +305,8 @@ void tr_torrentSetMetadataPiece(tr_torrent* tor, int piece, void const* data, in
|
|||
|
||||
if (success)
|
||||
{
|
||||
/* keep the new info */
|
||||
std::swap(tor->info, info->info);
|
||||
std::swap(tor->infoDictLength, info->info_dict_length);
|
||||
/* tor should keep this metainfo */
|
||||
tor->swapMetainfo(*info);
|
||||
|
||||
/* save the new .torrent file */
|
||||
tr_variantToFile(&newMetainfo, TR_VARIANT_FMT_BENC, tor->info.torrent);
|
||||
|
|
|
@ -989,7 +989,7 @@ tr_torrent* tr_torrentNew(tr_ctor const* ctor, int* setme_error, int* setme_dupl
|
|||
}
|
||||
|
||||
auto* tor = new tr_torrent{};
|
||||
tor->takeMetainfo(std::move(*parsed));
|
||||
tor->swapMetainfo(*parsed);
|
||||
torrentInit(tor, ctor);
|
||||
return tor;
|
||||
}
|
||||
|
@ -3601,7 +3601,7 @@ void tr_torrentRenamePath(
|
|||
tor->renamePath(oldpath, newname, callback, callback_user_data);
|
||||
}
|
||||
|
||||
void tr_torrent::takeMetainfo(tr_metainfo_parsed&& parsed)
|
||||
void tr_torrent::swapMetainfo(tr_metainfo_parsed& parsed)
|
||||
{
|
||||
std::swap(this->info, parsed.info);
|
||||
std::swap(this->piece_checksums_, parsed.pieces);
|
||||
|
|
|
@ -151,7 +151,7 @@ public:
|
|||
// because much of tr_torrent's impl is in the non-member C bindings
|
||||
//
|
||||
// private:
|
||||
void takeMetainfo(tr_metainfo_parsed&& parsed);
|
||||
void swapMetainfo(tr_metainfo_parsed& parsed);
|
||||
|
||||
public:
|
||||
auto unique_lock() const
|
||||
|
|
Loading…
Add table
Reference in a new issue