From: Anton Mitrofanov Date: Fri, 18 Jun 2010 21:44:56 +0000 (+0400) Subject: Fix SIGPIPEs caused by is_regular_file checks X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=8060431f0d60f97a9b5274ceb230fbcdb3e2cffd;p=x264 Fix SIGPIPEs caused by is_regular_file checks Check to see if input file is a pipe without opening it. --- diff --git a/common/osdep.h b/common/osdep.h index b1b357c0..b3a8cd6c 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 a124083a..09bad61c 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" );