(libT) fix dangling pointer in tor->currentDir when reloading a .resume file from disk
This commit is contained in:
parent
1eb2933fc5
commit
9c550b5a78
|
@ -728,8 +728,11 @@ loadFromFile (tr_torrent * tor, uint64_t fieldsToLoad)
|
||||||
&& (tr_variantDictFindStr (&top, TR_KEY_destination, &str, &len))
|
&& (tr_variantDictFindStr (&top, TR_KEY_destination, &str, &len))
|
||||||
&& (str && *str))
|
&& (str && *str))
|
||||||
{
|
{
|
||||||
|
const bool is_current_dir = tor->currentDir == tor->downloadDir;
|
||||||
tr_free (tor->downloadDir);
|
tr_free (tor->downloadDir);
|
||||||
tor->downloadDir = tr_strndup (str, len);
|
tor->downloadDir = tr_strndup (str, len);
|
||||||
|
if (is_current_dir)
|
||||||
|
tor->currentDir = tor->downloadDir;
|
||||||
fieldsLoaded |= TR_FR_DOWNLOAD_DIR;
|
fieldsLoaded |= TR_FR_DOWNLOAD_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,8 +740,11 @@ loadFromFile (tr_torrent * tor, uint64_t fieldsToLoad)
|
||||||
&& (tr_variantDictFindStr (&top, TR_KEY_incomplete_dir, &str, &len))
|
&& (tr_variantDictFindStr (&top, TR_KEY_incomplete_dir, &str, &len))
|
||||||
&& (str && *str))
|
&& (str && *str))
|
||||||
{
|
{
|
||||||
|
const bool is_current_dir = tor->currentDir == tor->incompleteDir;
|
||||||
tr_free (tor->incompleteDir);
|
tr_free (tor->incompleteDir);
|
||||||
tor->incompleteDir = tr_strndup (str, len);
|
tor->incompleteDir = tr_strndup (str, len);
|
||||||
|
if (is_current_dir)
|
||||||
|
tor->currentDir = tor->incompleteDir;
|
||||||
fieldsLoaded |= TR_FR_INCOMPLETE_DIR;
|
fieldsLoaded |= TR_FR_INCOMPLETE_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue