Commit ed3e4d07 authored by Laurent Aimar's avatar Laurent Aimar

Fixed 2 segfaults in config_OpenConfigFile.

parent cbc66ff6
...@@ -755,38 +755,39 @@ void __config_ResetAll( vlc_object_t *p_this ) ...@@ -755,38 +755,39 @@ void __config_ResetAll( vlc_object_t *p_this )
} }
static FILE *config_OpenConfigFile (vlc_object_t *obj, const char *mode) static FILE *config_OpenConfigFile( vlc_object_t *p_obj, const char *mode )
{ {
static const char subpath[] = DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE; static const char psz_subpath[] = DIR_SEP CONFIG_DIR DIR_SEP CONFIG_FILE;
const char *filename = obj->p_libvlc->psz_configfile; const char *psz_filename = p_obj->p_libvlc->psz_configfile;
const char *homedir; const char *psz_homedir;
size_t buflen = 0; size_t i_buflen = 0;
FILE *p_stream;
if (filename == NULL) if( psz_filename == NULL )
{ {
homedir = obj->p_libvlc->psz_homedir; psz_homedir = p_obj->p_libvlc->psz_homedir;
if (homedir == NULL) if( psz_homedir == NULL )
{ {
msg_Err (obj, "no home directory defined"); msg_Err( p_obj, "no home directory defined" );
return NULL; return NULL;
} }
buflen = strlen (homedir) + sizeof (subpath); i_buflen = strlen(psz_homedir) + sizeof(psz_subpath) + 1;
} }
char buf[buflen]; char buf[i_buflen];
if (filename == NULL) if( psz_filename == NULL )
{ {
sprintf (buf, "%s%s", homedir, subpath); sprintf( buf, "%s%s", psz_homedir, psz_subpath );
filename = buf; psz_filename = buf;
} }
msg_Dbg (obj, "opening config file (%s)", filename); msg_Dbg( p_obj, "opening config file (%s)", psz_filename );
FILE *stream = utf8_fopen (filename, mode); p_stream = utf8_fopen( psz_filename, mode );
if ((stream == NULL) && (errno != ENOENT)) if( p_stream == NULL && errno != ENOENT )
msg_Err (obj, "cannot open config file (%s): %s", strerror (errno)); msg_Err( p_obj, "cannot open config file (%s): %s", psz_filename, strerror(errno) );
return stream; return p_stream;
} }
......
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