[PATCH 2/2] libmpdemux/demux_mf: Don't crash if no paths were selected

Alexander Strasser <[email protected]> Tue, 27 Apr 2021 09:16:58 +0200
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <752f6c4401513f4e3d69867365bc006827521212.1619506206.git.eclipse7@gmx.net>
If open_mf in demux_open_mf returns an object with zero paths:
Return directly without returning a demuxer object.

Previously we segfaulted e.g. when trying to access the first
path to guess its file type.

Signed-off-by: Alexander Strasser <[email protected]>
---
 libmpdemux/demux_mf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmpdemux/demux_mf.c b/libmpdemux/demux_mf.c
index 1f322cd41..68a51665f 100644
--- a/libmpdemux/demux_mf.c
+++ b/libmpdemux/demux_mf.c
@@ -126,7 +126,7 @@ static demuxer_t* demux_open_mf(demuxer_t* demuxer){


   mf=open_mf(demuxer->stream->url + 5);
-  if(!mf) return NULL;
+  if(!mf || mf->nr_of_files == 0) return NULL;

   if(!mf_type){
     char* p=strrchr(mf->names[0],'.');
--