From 9c550b5a78758830a575cce879fb921efd1f8a47 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 31 Jan 2013 21:57:08 +0000 Subject: [PATCH] (libT) fix dangling pointer in tor->currentDir when reloading a .resume file from disk --- libtransmission/resume.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libtransmission/resume.c b/libtransmission/resume.c index 0cd641157..5767b64fd 100644 --- a/libtransmission/resume.c +++ b/libtransmission/resume.c @@ -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; } -- 2.40.0