[x264-devel] cli: Verify that yuv/y4m input has at least one frame of data
Henrik Gramner
git at videolan.org
Mon May 22 00:00:19 CEST 2017
x264 | branch: master | Henrik Gramner <henrik at gramner.com> | Fri May 19 16:08:34 2017 +0200| [d32d7bf1c6923a42cbd5ac2fd540ecbb009ba681] | committer: Henrik Gramner
cli: Verify that yuv/y4m input has at least one frame of data
Prevents a SIGBUS crash caused by attempting to access a memory-mapped
region beyond the end of the input file.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=d32d7bf1c6923a42cbd5ac2fd540ecbb009ba681
---
input/raw.c | 1 +
input/y4m.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/input/raw.c b/input/raw.c
index f8c04063..1f2e73e5 100644
--- a/input/raw.c
+++ b/input/raw.c
@@ -98,6 +98,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
uint64_t size = ftell( h->fh );
fseek( h->fh, 0, SEEK_SET );
info->num_frames = size / h->frame_size;
+ FAIL_IF_ERROR( !info->num_frames, "empty input file\n" );
/* Attempt to use memory-mapped input frames if possible */
if( !(h->bit_depth & 7) )
diff --git a/input/y4m.c b/input/y4m.c
index 8948f684..09dbb139 100644
--- a/input/y4m.c
+++ b/input/y4m.c
@@ -223,6 +223,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
uint64_t i_size = ftell( h->fh );
fseek( h->fh, init_pos, SEEK_SET );
info->num_frames = (i_size - h->seq_header_len) / h->frame_size;
+ FAIL_IF_ERROR( !info->num_frames, "empty input file\n" );
/* Attempt to use memory-mapped input frames if possible */
if( !(h->bit_depth & 7) )
More information about the x264-devel
mailing list