From: Jordan Lee Date: Sun, 27 Jan 2013 06:19:33 +0000 (+0000) Subject: (libT) #5259 'Minor memory leak in tr_torrentDeleteLocalData()' -- fixed. X-Git-Tag: 2.80~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9940acf756ed4f7702a6c083b4c9c089dde0ba3;p=transmission (libT) #5259 'Minor memory leak in tr_torrentDeleteLocalData()' -- fixed. --- diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 02404675f..a27cb0f44 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -2830,14 +2830,14 @@ deleteLocalData (tr_torrent * tor, tr_fileFunc func) if (!tr_is_same_file (top, dir) && strcmp (top, dir)) { for (;;) { char * parent = tr_dirname (dir); - if (tr_is_same_file (top, parent) || !strcmp (top, parent)) { - if (tr_ptrArrayFindSorted (&folders, dir, vstrcmp) == NULL) { - tr_ptrArrayInsertSorted (&folders, tr_strdup (dir), vstrcmp); - } - break; - } - tr_free (dir); + const bool done_walking = tr_is_same_file (top, parent) || !strcmp (top, parent); + if (done_walking && tr_ptrArrayFindSorted (&folders, dir, vstrcmp)) + tr_ptrArrayInsertSorted (&folders, dir, vstrcmp); /* folders assumes ownership of dir */ + else + tr_free (dir); dir = parent; + if (done_walking) + break; } } tr_free (dir);