mirror of
https://github.com/transmission/transmission
synced 2025-03-03 18:25:35 +00:00
(trunk libT) fix warnings in fileset_get_empty_slot() found by llvm's static-build analyzer.
static-build found a potential NULL pointer dereference. The circumstances where this could get triggered don't seem very likely, but doesn't hurt to fix the warning.
This commit is contained in:
parent
206b1a9a5f
commit
0d13057111
1 changed files with 17 additions and 11 deletions
|
@ -478,8 +478,11 @@ fileset_lookup( struct tr_fileset * set, int torrent_id, tr_file_index_t i )
|
|||
static struct tr_cached_file *
|
||||
fileset_get_empty_slot( struct tr_fileset * set )
|
||||
{
|
||||
struct tr_cached_file * cull = NULL;
|
||||
|
||||
if( set->begin != NULL )
|
||||
{
|
||||
struct tr_cached_file * o;
|
||||
struct tr_cached_file * cull;
|
||||
|
||||
/* try to find an unused slot */
|
||||
for( o=set->begin; o!=set->end; ++o )
|
||||
|
@ -490,7 +493,10 @@ fileset_get_empty_slot( struct tr_fileset * set )
|
|||
for( cull=NULL, o=set->begin; o!=set->end; ++o )
|
||||
if( !cull || o->used_at < cull->used_at )
|
||||
cull = o;
|
||||
|
||||
cached_file_close( cull );
|
||||
}
|
||||
|
||||
return cull;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue