From 8cd645f0a2b49723bd5adbc236b2eb9b29276cdf Mon Sep 17 00:00:00 2001 From: richardash1981 Date: Sun, 28 Mar 2010 20:23:47 +0000 Subject: [PATCH] Add a patch by Al Diamond to fix a crash in ufile_fopen_input(), signed off by me. --- src/FFmpeg.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 28fa41029..e89edd2f0 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -324,6 +324,13 @@ int ufile_fopen_input(AVFormatContext **ic_ptr, wxString & name) // Read up to a "probe_size" worth of data pd.buf_size = FFmpegLibsInst->get_buffer(pb, pd.buf, probe_size); + // AWD: with zero-length input files buf_size can come back negative; + // this causes problems so we might as well just fail + if (pd.buf_size < 0) { + err = AVERROR_INVALIDDATA; + goto fail; + } + // Clear up to a "AVPROBE_PADDING_SIZE" worth of unused buffer memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);