Commit bc21bdf0 authored by Rémi Duraffort's avatar Rémi Duraffort

hotkeys: fix potential buffer overflows, use var_CreateGetString,

fix memleaks and use pl_Release.
parent e3895ba9
/***************************************************************************** /*****************************************************************************
* hotkeys.c: Hotkey handling for vlc * hotkeys.c: Hotkey handling for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2005 the VideoLAN team * Copyright (C) 2005-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Sigmund Augdal Helberg <dnumgis@videolan.org> * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
...@@ -952,15 +952,13 @@ static int ActionEvent( vlc_object_t *libvlc, char const *psz_var, ...@@ -952,15 +952,13 @@ static int ActionEvent( vlc_object_t *libvlc, char const *psz_var,
static void PlayBookmark( intf_thread_t *p_intf, int i_num ) static void PlayBookmark( intf_thread_t *p_intf, int i_num )
{ {
vlc_value_t val; char *psz_bookmark_name;
char psz_bookmark_name[11]; if( asprintf( &psz_bookmark_name, "bookmark%i", i_num ) == -1 )
playlist_t *p_playlist = pl_Hold( p_intf ); return;
sprintf( psz_bookmark_name, "bookmark%i", i_num ); playlist_t *p_playlist = pl_Hold( p_intf );
var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT ); char *psz_bookmark = var_CreateGetString( p_intf, psz_bookmark_name );
var_Get( p_intf, psz_bookmark_name, &val );
char *psz_bookmark = strdup( val.psz_string );
PL_LOCK; PL_LOCK;
FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items ) FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )
char *psz_uri = input_item_GetURI( p_item->p_input ); char *psz_uri = input_item_GetURI( p_item->p_input );
...@@ -975,15 +973,19 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num ) ...@@ -975,15 +973,19 @@ static void PlayBookmark( intf_thread_t *p_intf, int i_num )
free( psz_uri ); free( psz_uri );
FOREACH_END(); FOREACH_END();
PL_UNLOCK; PL_UNLOCK;
free( psz_bookmark ); free( psz_bookmark );
vlc_object_release( p_playlist ); free( psz_bookmark_name );
pl_Release( p_intf );
} }
static void SetBookmark( intf_thread_t *p_intf, int i_num ) static void SetBookmark( intf_thread_t *p_intf, int i_num )
{ {
char *psz_bookmark_name;
if( asprintf( &psz_bookmark_name, "bookmark%i", i_num ) == -1 )
return;
playlist_t *p_playlist = pl_Hold( p_intf ); playlist_t *p_playlist = pl_Hold( p_intf );
char psz_bookmark_name[11];
sprintf( psz_bookmark_name, "bookmark%i", i_num );
var_Create( p_intf, psz_bookmark_name, var_Create( p_intf, psz_bookmark_name,
VLC_VAR_STRING|VLC_VAR_DOINHERIT ); VLC_VAR_STRING|VLC_VAR_DOINHERIT );
playlist_item_t * p_item = playlist_CurrentPlayingItem( p_playlist ); playlist_item_t * p_item = playlist_CurrentPlayingItem( p_playlist );
...@@ -995,7 +997,9 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num ) ...@@ -995,7 +997,9 @@ static void SetBookmark( intf_thread_t *p_intf, int i_num )
free( psz_uri ); free( psz_uri );
config_SaveConfigFile( p_intf, "hotkeys" ); config_SaveConfigFile( p_intf, "hotkeys" );
} }
pl_Release( p_intf ); pl_Release( p_intf );
free( psz_bookmark_name );
} }
static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout, static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
......
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