[x264-devel] commit: Fix SIGPIPEs caused by is_regular_file checks (Anton Mitrofanov )

git at videolan.org git at videolan.org
Fri Jun 25 09:58:11 CEST 2010


x264 | branch: stable | Anton Mitrofanov <BugMaster at narod.ru> | Sat Jun 19 01:44:56 2010 +0400| [69e9d85c292cb9daa96664657352bf6c65af5825] | committer: Jason Garrett-Glaser 

Fix SIGPIPEs caused by is_regular_file checks
Check to see if input file is a pipe without opening it.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=69e9d85c292cb9daa96664657352bf6c65af5825
---

 common/osdep.h |   10 +++++++++-
 x264.c         |    1 +
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/common/osdep.h b/common/osdep.h
index b1b357c..b3a8cd6 100644
--- a/common/osdep.h
+++ b/common/osdep.h
@@ -290,7 +290,15 @@ static inline uint8_t x264_is_regular_file( FILE *filehandle )
 {
     struct stat file_stat;
     if( fstat( fileno( filehandle ), &file_stat ) )
-        return 0;
+        return -1;
+    return S_ISREG( file_stat.st_mode );
+}
+
+static inline uint8_t x264_is_regular_file_path( const char *filename )
+{
+    struct stat file_stat;
+    if( stat( filename, &file_stat ) )
+        return -1;
     return S_ISREG( file_stat.st_mode );
 }
 
diff --git a/x264.c b/x264.c
index a124083..09bad61 100644
--- a/x264.c
+++ b/x264.c
@@ -806,6 +806,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename
     int b_auto = !strcasecmp( demuxer, "auto" );
     if( !b_regular && b_auto )
         ext = "yuv";
+    b_regular = b_regular && x264_is_regular_file_path( filename );
     if( b_regular )
     {
         FILE *f = fopen( filename, "r" );



More information about the x264-devel mailing list