[vlc-commits] input/control: INPUT_{ADD, CHANGE}_BOOKMARK: do not add incomplete bookmark
Filip Roséen
git at videolan.org
Thu May 18 18:20:52 CEST 2017
vlc | branch: master | Filip Roséen <filip at atch.se> | Thu May 18 12:29:43 2017 +0200| [7ed4729e023d00cd98b6b550d0e636b52e07c9f1] | committer: Rémi Denis-Courmont
input/control: INPUT_{ADD, CHANGE}_BOOKMARK: do not add incomplete bookmark
A bookmark needs to have a name which is non-null to prevent potential
null-dereferences further down the road, priv->pp_bookmark shall also
not contain any null-pointers.
These changes make sure that the above invariant holds during
modification.
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ed4729e023d00cd98b6b550d0e636b52e07c9f1
---
src/input/control.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/input/control.c b/src/input/control.c
index 9a7ec7f867..5ead47e597 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -195,7 +195,7 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
}
case INPUT_ADD_BOOKMARK:
- p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
+ p_bkmk = va_arg( args, seekpoint_t * );
p_bkmk = vlc_seekpoint_Duplicate( p_bkmk );
vlc_mutex_lock( &priv->p_item->lock );
@@ -206,22 +206,33 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
p_bkmk->psz_name = NULL;
}
- TAB_APPEND( priv->i_bookmark, priv->pp_bookmark, p_bkmk );
+ if( p_bkmk->psz_name )
+ TAB_APPEND( priv->i_bookmark, priv->pp_bookmark, p_bkmk );
+ else
+ {
+ vlc_seekpoint_Delete( p_bkmk );
+ 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_CHANGE_BOOKMARK:
- p_bkmk = (seekpoint_t *)va_arg( args, seekpoint_t * );
- i_bkmk = (int)va_arg( args, int );
+ 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] = vlc_seekpoint_Duplicate( p_bkmk );
+ priv->pp_bookmark[i_bkmk] = p_bkmk;
}
vlc_mutex_unlock( &priv->p_item->lock );
More information about the vlc-commits
mailing list