mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
fix: check tr_ctorSetFoo() return values before adding torrent via RPC (#5202)
This commit is contained in:
parent
3039ff1390
commit
900281eb1c
1 changed files with 13 additions and 9 deletions
|
@ -1688,21 +1688,25 @@ char const* torrentAdd(tr_session* session, tr_variant* args_in, tr_variant* /*a
|
|||
}
|
||||
else
|
||||
{
|
||||
auto ok = false;
|
||||
|
||||
if (std::empty(filename))
|
||||
{
|
||||
auto const metainfo = tr_base64_decode(metainfo_base64);
|
||||
tr_ctorSetMetainfo(ctor, std::data(metainfo), std::size(metainfo), nullptr);
|
||||
ok = tr_ctorSetMetainfo(ctor, std::data(metainfo), std::size(metainfo), nullptr);
|
||||
}
|
||||
else if (tr_sys_path_exists(tr_pathbuf{ filename }))
|
||||
{
|
||||
ok = tr_ctorSetMetainfoFromFile(ctor, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tr_sys_path_exists(tr_pathbuf{ filename }))
|
||||
{
|
||||
tr_ctorSetMetainfoFromFile(ctor, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_ctorSetMetainfoFromMagnetLink(ctor, filename);
|
||||
}
|
||||
ok = tr_ctorSetMetainfoFromMagnetLink(ctor, filename);
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
return "unrecognized info";
|
||||
}
|
||||
|
||||
addTorrentImpl(idle_data, ctor);
|
||||
|
|
Loading…
Reference in a new issue