Use stat properly (you don't want to open directories or devices...)
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 18 Sep 2008 18:47:11 +0000 (21:47 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Thu, 18 Sep 2008 19:24:55 +0000 (22:24 +0300)
src/input/input.c

index 3623a73..1bcf200 100644 (file)
@@ -2643,9 +2643,8 @@ static char *InputGetExtraFiles( input_thread_t *p_input,
 
         snprintf( psz_ext, 5, ".%.3d", i );
 
 
         snprintf( psz_ext, 5, ".%.3d", i );
 
-        if( utf8_stat( psz_file, &st ) != 0 )
-            break;
-        if( st.st_size <= 0 )
+        if( utf8_stat( psz_file, &st )
+         || !S_ISREG( st.st_mode ) || !st.st_size )
             continue;
 
         msg_Dbg( p_input, "Detected extra file `%s'", psz_file );
             continue;
 
         msg_Dbg( p_input, "Detected extra file `%s'", psz_file );
@@ -2993,7 +2992,7 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
 
             strcpy( psz_extension, ".idx" );
 
 
             strcpy( psz_extension, ".idx" );
 
-            if( !utf8_stat( psz_path, &st ) )
+            if( !utf8_stat( psz_path, &st ) && S_ISREG( st.st_mode ) )
             {
                 msg_Dbg( p_input, "using %s subtitles file instead of %s",
                          psz_path, psz_subtitle );
             {
                 msg_Dbg( p_input, "using %s subtitles file instead of %s",
                          psz_path, psz_subtitle );