From 6d36b3d763f76bd2be261d32fe0c547a203467fe Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 11 Aug 2011 21:02:15 +0000 Subject: [PATCH] (trunk libT) #4377 "Incomplete Folder removed when sub-folder of Default Location" -- minor revision to r12665 to fix a minor memory leak with the 'subpath' string. --- libtransmission/torrent.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 3e46c9860..25bb0f0a3 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -2712,12 +2712,10 @@ removeEmptyFoldersAndJunkFiles( const char * folder ) if( strcmp( d->d_name, "." ) && strcmp( d->d_name, ".." ) ) { struct stat sb; char * filename = tr_buildPath( folder, d->d_name, NULL ); - if( !stat( filename, &sb ) ) { - if( S_ISDIR( sb.st_mode ) ) - removeEmptyFoldersAndJunkFiles( filename ); - else if( isJunkFile( d->d_name ) ) - remove( filename ); - } + if( !stat( filename, &sb ) && S_ISDIR( sb.st_mode ) ) + removeEmptyFoldersAndJunkFiles( filename ); + else if( isJunkFile( d->d_name ) ) + remove( filename ); tr_free( filename ); } } @@ -2774,6 +2772,7 @@ deleteLocalData( tr_torrent * tor, tr_fileFunc func ) tr_free( target_dir ); tr_free( target ); tr_free( source ); + tr_free( subpath ); } } @@ -2833,8 +2832,8 @@ deleteLocalData( tr_torrent * tor, tr_fileFunc func ) /* cleanup */ rmdir( tmpdir ); tr_free( tmpdir ); - tr_ptrArrayDestruct( &files, tr_free ); tr_ptrArrayDestruct( &folders, tr_free ); + tr_ptrArrayDestruct( &files, tr_free ); } static void