Commit 95024e06 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Don't access unallocated memory

parent e616477b
...@@ -82,22 +82,25 @@ struct access_sys_t ...@@ -82,22 +82,25 @@ struct access_sys_t
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int Open( vlc_object_t *p_this )
{ {
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys; access_sys_t *p_sys = NULL;
char *psz_name; char *psz_name = NULL;
char *psz, *psz_uri; char *psz = NULL;
GnomeVFSURI *p_uri; char *psz_uri = NULL;
GnomeVFSResult i_ret; GnomeVFSURI *p_uri = NULL;
GnomeVFSResult i_ret;
GnomeVFSHandle *p_handle = NULL;
if( !(gnome_vfs_init()) ) if( !(gnome_vfs_init()) )
{ {
msg_Warn( p_access, "couldn't initilize GnomeVFS" ); msg_Warn( p_access, "couldn't initilize GnomeVFS" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* FIXME /* FIXME
Since GnomeVFS segfaults on exit if we initialize it without trying to Since GnomeVFS segfaults on exit if we initialize it without trying to
open a file with a valid protocol, try top open at least file:// */ open a file with a valid protocol, try to open at least file:// */
gnome_vfs_open( &(p_sys->p_handle), "file://", 5 ); gnome_vfs_open( &p_handle, "file://", 5 );
p_access->pf_read = Read; p_access->pf_read = Read;
p_access->pf_block = NULL; p_access->pf_block = NULL;
...@@ -109,11 +112,15 @@ static int Open( vlc_object_t *p_this ) ...@@ -109,11 +112,15 @@ static int Open( vlc_object_t *p_this )
p_access->info.b_eof = VLC_FALSE; p_access->info.b_eof = VLC_FALSE;
p_access->info.i_title = 0; p_access->info.i_title = 0;
p_access->info.i_seekpoint = 0; p_access->info.i_seekpoint = 0;
p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->p_handle = p_handle;
p_sys->i_nb_reads = 0; p_sys->i_nb_reads = 0;
p_sys->b_pace_control = VLC_TRUE; p_sys->b_pace_control = VLC_TRUE;
if( strcmp( "gnomevfs", p_access->psz_access ) && if( strcmp( "gnomevfs", p_access->psz_access ) &&
*(p_access->psz_access) != '\0') *(p_access->psz_access) != '\0')
{ {
...@@ -142,7 +149,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -142,7 +149,6 @@ static int Open( vlc_object_t *p_this )
} }
p_uri = gnome_vfs_uri_new( psz_uri ); p_uri = gnome_vfs_uri_new( psz_uri );
if( p_uri ) if( p_uri )
{ {
p_sys->p_file_info = gnome_vfs_file_info_new(); p_sys->p_file_info = gnome_vfs_file_info_new();
...@@ -230,7 +236,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -230,7 +236,6 @@ static int Open( vlc_object_t *p_this )
p_sys->psz_name = psz_name; p_sys->psz_name = psz_name;
gnome_vfs_uri_unref( p_uri); gnome_vfs_uri_unref( p_uri);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -261,12 +266,11 @@ static void Close( vlc_object_t * p_this ) ...@@ -261,12 +266,11 @@ static void Close( vlc_object_t * p_this )
static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
int i_ret;
GnomeVFSFileSize i_read_len; GnomeVFSFileSize i_read_len;
int i_ret;
i_ret = gnome_vfs_read( p_sys->p_handle, p_buffer, i_ret = gnome_vfs_read( p_sys->p_handle, p_buffer,
(GnomeVFSFileSize)i_len, &i_read_len ); (GnomeVFSFileSize)i_len, &i_read_len );
if( i_ret ) if( i_ret )
{ {
p_access->info.b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
...@@ -319,7 +323,6 @@ static int Seek( access_t *p_access, int64_t i_pos ) ...@@ -319,7 +323,6 @@ static int Seek( access_t *p_access, int64_t i_pos )
i_ret = gnome_vfs_seek( p_sys->p_handle, GNOME_VFS_SEEK_START, i_ret = gnome_vfs_seek( p_sys->p_handle, GNOME_VFS_SEEK_START,
(GnomeVFSFileOffset)i_pos); (GnomeVFSFileOffset)i_pos);
if ( !i_ret ) if ( !i_ret )
{ {
p_access->info.i_pos = i_pos; p_access->info.i_pos = i_pos;
...@@ -400,4 +403,3 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -400,4 +403,3 @@ static int Control( access_t *p_access, int i_query, va_list args )
} }
return VLC_SUCCESS; return VLC_SUCCESS;
} }
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