#5259 closed Bug (fixed)
Minor memory leak in tr_torrentDeleteLocalData()
Reported by: | jordan | Owned by: | jordan |
---|---|---|---|
Priority: | Normal | Milestone: | 2.80 |
Component: | libtransmission | Version: | 2.70 |
Severity: | Minor | Keywords: | |
Cc: |
Description
In the deleteLocalData() section that begins with the comment "build a list of 'top's child directories that belong to this torrent, we leak one instance of `dir' per file.
Change History (5)
comment:1 Changed 8 years ago by jordan
- Status changed from new to assigned
comment:2 Changed 8 years ago by jordan
- Resolution set to fixed
- Status changed from assigned to closed
comment:3 Changed 8 years ago by cfpp2p
wasn't this already fixed and verified by valgrind at r13203 ?
comment:4 Changed 8 years ago by cfpp2p
Here is an alternative fix for the memory leak. Since r13203 did not fix the leak completely lets start there for a clean fix:
/* build a list of 'top's child directories that belong to this torrent */ for( f=0; f<tor->info.fileCount; ++f ) { char * dir; char * filename; /* get the directory that this file goes in... */ filename = tr_buildPath( top, tor->info.files[f].name, NULL ); dir = tr_dirname( filename ); tr_free( filename ); 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 ) ) { /* break is guaranteed now */ tr_free( parent ); /* free parent now since dir won't point to it on break */ if( tr_ptrArrayFindSorted( &folders, dir, vstrcmp ) == NULL ) { tr_ptrArrayInsertSorted( &folders, tr_strdup( dir ), vstrcmp ); } break; } tr_free( dir ); /* free dir and maybe equivalent parent pointed to by prior */ dir = parent; /* point dir at current parent */ } } tr_free( dir ); /* free dir and maybe equivalent parent pointed to by prior */ }
comment:5 Changed 8 years ago by jordan
Yes, that's a little cleaner.
Slightly-futzed version applied in r13924
Note: See
TracTickets for help on using
tickets.
fixed in r13881