Commit 9f85beee authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix title N variable formatting

Do not assume the title number is small; allocate large enough buffer.
parent 3e48cead
...@@ -1266,19 +1266,15 @@ int libvlc_media_player_get_chapter_count_for_title( ...@@ -1266,19 +1266,15 @@ int libvlc_media_player_get_chapter_count_for_title(
libvlc_media_player_t *p_mi, libvlc_media_player_t *p_mi,
int i_title ) int i_title )
{ {
input_thread_t *p_input_thread;
vlc_value_t val; vlc_value_t val;
p_input_thread = libvlc_get_input_thread ( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
if( !p_input_thread ) if( !p_input_thread )
return -1; return -1;
char *psz_name; char psz_name[sizeof ("title ") + 3 * sizeof (int)];
if( asprintf( &psz_name, "title %2i", i_title ) == -1 ) sprintf( psz_name, "title %2u", i_title );
{
vlc_object_release( p_input_thread );
return -1;
}
int i_ret = var_Change( p_input_thread, psz_name, VLC_VAR_CHOICESCOUNT, &val, NULL ); int i_ret = var_Change( p_input_thread, psz_name, VLC_VAR_CHOICESCOUNT, &val, NULL );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
free( psz_name ); free( psz_name );
......
...@@ -405,8 +405,8 @@ libvlc_track_description_t * ...@@ -405,8 +405,8 @@ libvlc_track_description_t *
libvlc_video_get_chapter_description( libvlc_media_player_t *p_mi, libvlc_video_get_chapter_description( libvlc_media_player_t *p_mi,
int i_title ) int i_title )
{ {
char psz_title[12]; char psz_title[sizeof ("title ") + 3 * sizeof (int)];
sprintf( psz_title, "title %2i", i_title ); sprintf( psz_title, "title %2u", i_title );
return libvlc_get_track_description( p_mi, psz_title ); return libvlc_get_track_description( p_mi, psz_title );
} }
......
...@@ -1354,15 +1354,15 @@ void VLCMenuBar::UpdateItem( intf_thread_t *p_intf, QMenu *menu, ...@@ -1354,15 +1354,15 @@ void VLCMenuBar::UpdateItem( intf_thread_t *p_intf, QMenu *menu,
#undef TEXT_OR_VAR #undef TEXT_OR_VAR
/** HACK for the navigation submenu: /** HACK for the navigation submenu:
* "title %2i" variables take the value 0 if not set * "title %2u" variables take the value 0 if not set
*/ */
static bool CheckTitle( vlc_object_t *p_object, const char *psz_var ) static bool CheckTitle( vlc_object_t *p_object, const char *psz_var )
{ {
int i_title = 0; unsigned i_title = 0;
if( sscanf( psz_var, "title %2i", &i_title ) <= 0 ) if( sscanf( psz_var, "title %2u", &i_title ) <= 0 )
return true; return true;
int i_current_title = var_GetInteger( p_object, "title" ); unsigned i_current_title = var_GetInteger( p_object, "title" );
return ( i_title == i_current_title ); return ( i_title == i_current_title );
} }
......
...@@ -149,9 +149,9 @@ void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekp ...@@ -149,9 +149,9 @@ void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekp
val.i_int = i_seekpoint; val.i_int = i_seekpoint;
var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
/* "title %2i" */ /* "title %2u" */
char psz_title[10]; char psz_title[sizeof ("title ") + 3 * sizeof (int)];
snprintf( psz_title, sizeof(psz_title), "title %2i", i_title ); sprintf( psz_title, "title %2u", i_title );
var_Change( p_input, psz_title, VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, psz_title, VLC_VAR_SETVALUE, &val, NULL );
/* */ /* */
......
...@@ -235,15 +235,14 @@ void input_ControlVarStop( input_thread_t *p_input ) ...@@ -235,15 +235,14 @@ void input_ControlVarStop( input_thread_t *p_input )
if( p_input->p->i_title > 0 ) if( p_input->p->i_title > 0 )
{ {
char name[sizeof("title ") + 5 ];
int i;
InputDelCallbacks( p_input, p_input_navigation_callbacks ); InputDelCallbacks( p_input, p_input_navigation_callbacks );
InputDelCallbacks( p_input, p_input_title_callbacks ); InputDelCallbacks( p_input, p_input_title_callbacks );
for( i = 0; i < p_input->p->i_title; i++ ) for( int i = 0; i < p_input->p->i_title; i++ )
{ {
snprintf( name, sizeof(name), "title %2i", i ); char name[sizeof("title ") + 3 * sizeof (int)];
sprintf( name, "title %2u", i );
var_DelCallback( p_input, name, NavigationCallback, (void *)(intptr_t)i ); var_DelCallback( p_input, name, NavigationCallback, (void *)(intptr_t)i );
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment