[MPlayer-dev-eng] [PATCH 3/4] libmpdemux/mf: init_mf_from_glob_pattern: Use same signedness in comparison

Alexander Strasser eclipse7 at gmx.net
Tue Jun 1 23:05:58 EEST 2021


Additionally detect if the number of matches of glob was bigger than
what fits into signed int and fail in that case.

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 libmpdemux/mf.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libmpdemux/mf.c b/libmpdemux/mf.c
index 7e75b714c..89fc2a7a0 100644
--- a/libmpdemux/mf.c
+++ b/libmpdemux/mf.c
@@ -118,11 +118,18 @@ static int init_mf_from_glob_pattern(mf_t* mf, const char * filename){
     { free( fname ); return 0; }

    mf->nr_of_files=gg.gl_pathc;
+   if (mf->nr_of_files < 0)
+    {
+     mf->nr_of_files = 0;
+     free( fname );
+     globfree( &gg );
+     return 0;
+    }
    mf->names=calloc( gg.gl_pathc, sizeof( char* ) );

    mp_msg( MSGT_STREAM, MSGL_INFO, "[mf] number of files: %d (%zu)\n", mf->nr_of_files, gg.gl_pathc * sizeof( char* ) );

-   for( i=0;i < gg.gl_pathc;i++ )
+   for( i=0;i < mf->nr_of_files;i++ )
     {
      struct stat fs;
      if (stat( gg.gl_pathv[i],&fs ) == -1) continue;
--


More information about the MPlayer-dev-eng mailing list