diff options
author | wm4 <wm4@nowhere> | 2013-03-19 01:54:45 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-03-19 01:54:45 +0100 |
commit | be7e04f7198ed6092a1d1e54e867df9b2c6247a4 (patch) | |
tree | 5719fd9763e4ee3bf736e1be588a59c1aa88ab7f /demux/mf.c | |
parent | b242aa366bc10b0dd0504f3c3c916e4e61e4f81b (diff) | |
download | mpv-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.
Diffstat (limited to 'demux/mf.c')
-rw-r--r-- | demux/mf.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; } |