summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-19 01:54:45 +0100
committerwm4 <wm4@nowhere>2013-03-19 01:54:45 +0100
commitbe7e04f7198ed6092a1d1e54e867df9b2c6247a4 (patch)
tree5719fd9763e4ee3bf736e1be588a59c1aa88ab7f
parentb242aa366bc10b0dd0504f3c3c916e4e61e4f81b (diff)
downloadmpv-be7e04f7198ed6092a1d1e54e867df9b2c6247a4.tar.bz2
mpv-be7e04f7198ed6092a1d1e54e867df9b2c6247a4.tar.xz
demux_mf: fix crashes when '*' matches directories
Doing 'mpv mf://*' in a file with directories would crash, because even though directories are skipped, the corresponding file entry is just left at NULL, leading to a segfault on access. So explicitly skip NULL entries.
-rw-r--r--demux/demux_mf.c9
-rw-r--r--demux/mf.c8
2 files changed, 10 insertions, 7 deletions
diff --git a/demux/demux_mf.c b/demux/demux_mf.c
index 236718de36..0db3fb8add 100644
--- a/demux/demux_mf.c
+++ b/demux/demux_mf.c
@@ -70,8 +70,11 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){
if (mf->streams)
entry_stream = mf->streams[mf->curr_frame];
struct stream *stream = entry_stream;
- if (!stream)
- stream = open_stream(mf->names[mf->curr_frame], demuxer->opts, NULL);
+ if (!stream) {
+ char *filename = mf->names[mf->curr_frame];
+ if (filename)
+ stream = open_stream(filename, demuxer->opts, NULL);
+ }
if (stream) {
stream_seek(stream, 0);
@@ -87,7 +90,7 @@ static int demux_mf_fill_buffer(demuxer_t *demuxer, demux_stream_t *ds){
talloc_free(data.start);
}
- if (stream != entry_stream)
+ if (stream && stream != entry_stream)
free_stream(stream);
mf->curr_frame++;
diff --git a/demux/mf.c b/demux/mf.c
index 98fab6edc4..21c3fad186 100644
--- a/demux/mf.c
+++ b/demux/mf.c
@@ -128,18 +128,18 @@ mf_t* open_mf_pattern(char * filename)
if ( glob( fname,0,NULL,&gg ) )
{ free( mf ); free( fname ); return NULL; }
- mf->nr_of_files=gg.gl_pathc;
+ mf->nr_of_files=0;
mf->names=calloc( gg.gl_pathc, sizeof( char* ) );
- mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d (%zd)\n",mf->nr_of_files, gg.gl_pathc * sizeof( char* ) );
-
for( i=0;i < gg.gl_pathc;i++ )
{
if (mp_path_isdir(gg.gl_pathv[i]))
continue;
- mf->names[i]=strdup( gg.gl_pathv[i] );
+ mf->names[mf->nr_of_files]=strdup( gg.gl_pathv[i] );
+ mf->nr_of_files++;
// mp_msg( MSGT_STREAM,MSGL_DBG2,"[mf] added file %d.: %s\n",i,mf->names[i] );
}
+ mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files);
globfree( &gg );
goto exit_mf;
}