]> granicus.if.org Git - transmission/commitdiff
(libT) fix dangling pointer in tor->currentDir when reloading a .resume file from...
authorJordan Lee <jordan@transmissionbt.com>
Thu, 31 Jan 2013 21:57:08 +0000 (21:57 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Thu, 31 Jan 2013 21:57:08 +0000 (21:57 +0000)
libtransmission/resume.c

index 0cd64115747cdf5f42636b3ecb8775db758dacdb..5767b64fd77d3a756c910aab0f769eb64d057cad 100644 (file)
@@ -728,8 +728,11 @@ loadFromFile (tr_torrent * tor, uint64_t fieldsToLoad)
       && (tr_variantDictFindStr (&top, TR_KEY_destination, &str, &len))
       && (str && *str))
     {
+        const bool is_current_dir = tor->currentDir == tor->downloadDir;
         tr_free (tor->downloadDir);
         tor->downloadDir = tr_strndup (str, len);
+        if (is_current_dir)
+          tor->currentDir = tor->downloadDir;
         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))
       && (str && *str))
     {
+        const bool is_current_dir = tor->currentDir == tor->incompleteDir;
         tr_free (tor->incompleteDir);
         tor->incompleteDir = tr_strndup (str, len);
+        if (is_current_dir)
+          tor->currentDir = tor->incompleteDir;
         fieldsLoaded |= TR_FR_INCOMPLETE_DIR;
     }