vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sun Sep 27 20:58:07 2020 +0300| [56aa955bf55f84c038db633b85ab0481e2bafe8e] | committer: Rémi Denis-Courmont
item: check for allocation failure just once Not thrice. > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=56aa955bf55f84c038db633b85ab0481e2bafe8e --- src/input/item.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/input/item.c b/src/input/item.c index 714a839dda..7a69f5b448 100644 --- a/src/input/item.c +++ b/src/input/item.c @@ -1112,7 +1112,13 @@ input_item_t *input_item_Copy( input_item_t *p_input ) item = input_item_NewExt( p_input->psz_uri, p_input->psz_name, p_input->i_duration, p_input->i_type, ITEM_NET_UNKNOWN ); - if( likely(item != NULL) && p_input->p_meta != NULL ) + if( unlikely(item == NULL) ) + { + vlc_mutex_unlock( &p_input->lock ); + return NULL; + } + + if( p_input->p_meta != NULL ) { meta = vlc_meta_New(); if( likely(meta != NULL) ) @@ -1120,7 +1126,7 @@ input_item_t *input_item_Copy( input_item_t *p_input ) } b_net = p_input->b_net; - if( likely(item != NULL) && p_input->i_slaves > 0 ) + if( p_input->i_slaves > 0 ) { for( int i = 0; i < p_input->i_slaves; i++ ) { @@ -1137,13 +1143,10 @@ input_item_t *input_item_Copy( input_item_t *p_input ) vlc_mutex_unlock( &p_input->lock ); - if( likely(item != NULL) ) - { /* No need to lock; no other thread has seen this new item yet. */ - input_item_CopyOptions( item, p_input ); - item->p_meta = meta; - item->b_net = b_net; - } - + /* No need to lock; no other thread has seen this new item yet. */ + input_item_CopyOptions( item, p_input ); + item->p_meta = meta; + item->b_net = b_net; return item; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
