[vlc-commits] input/control: INPUT_CHANGE_BOOKMARK: fix leak and return
Filip Roséen
git at videolan.org
Fri May 19 09:40:13 CEST 2017
vlc | branch: master | Filip Roséen <filip at atch.se> | Fri May 19 09:30:36 2017 +0200| [db9941a7a89a9e2c5356c956c0ba3079080e66fe] | committer: Thomas Guillem
input/control: INPUT_CHANGE_BOOKMARK: fix leak and return
The previous implementation would potentially try to duplicate a
seekpoint that was never used due to invalid arguments, as well as
leaking said duplicate.
These changes make sure that we do not leak the resource, while also
preventing the unnecessary duplication + returning an error if
we are unable to complete the operation.
CID: 1409711
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=db9941a7a89a9e2c5356c956c0ba3079080e66fe
---
src/input/control.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/input/control.c b/src/input/control.c
index 904dcc17a2..6062a30a0d 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -222,22 +222,22 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
p_bkmk = va_arg( args, seekpoint_t * );
i_bkmk = va_arg( args, int );
- p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
-
- if( !p_bkmk )
- return VLC_EGENERIC;
-
vlc_mutex_lock( &priv->p_item->lock );
if( i_bkmk < priv->i_bookmark )
{
- vlc_seekpoint_Delete( priv->pp_bookmark[i_bkmk] );
- priv->pp_bookmark[i_bkmk] = p_bkmk;
+ p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
+ if( p_bkmk )
+ {
+ vlc_seekpoint_Delete( priv->pp_bookmark[i_bkmk] );
+ priv->pp_bookmark[i_bkmk] = p_bkmk;
+ }
}
+ else p_bkmk = NULL;
vlc_mutex_unlock( &priv->p_item->lock );
UpdateBookmarksOption( p_input );
- return VLC_SUCCESS;
+ return p_bkmk ? VLC_SUCCESS : VLC_EGENERIC;
case INPUT_DEL_BOOKMARK:
i_bkmk = va_arg( args, int );
More information about the vlc-commits
mailing list