[FFmpeg-cvslog] avcodec/shorten: Move buffer allocation and offset init to end of read_header()
Michael Niedermayer
git at videolan.org
Tue Sep 12 03:48:52 EEST 2017
ffmpeg | branch: release/3.3 | Michael Niedermayer <michael at niedermayer.cc> | Sun Sep 10 21:10:16 2017 +0200| [0c5eb03aac6fd31ebb3e4ec263b18de30836c5a2] | committer: Michael Niedermayer
avcodec/shorten: Move buffer allocation and offset init to end of read_header()
They are time consuming operations, performing them after the other checks
improves the speed with damaged input dramatically.
Fixes: Timeout
Fixes: 2928/clusterfuzz-testcase-4992812120539136
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 380659604f2692b625928a3a76a1c046f473c9f6)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c5eb03aac6fd31ebb3e4ec263b18de30836c5a2
---
libavcodec/shorten.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 920887b2a0..3b0fa272e7 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -462,12 +462,6 @@ static int read_header(ShortenContext *s)
}
s->nwrap = FFMAX(NWRAP, maxnlpc);
- if ((ret = allocate_buffers(s)) < 0)
- return ret;
-
- if ((ret = init_offset(s)) < 0)
- return ret;
-
if (s->version > 1)
s->lpcqoffset = V2LPCQOFFSET;
@@ -504,6 +498,13 @@ static int read_header(ShortenContext *s)
}
end:
+
+ if ((ret = allocate_buffers(s)) < 0)
+ return ret;
+
+ if ((ret = init_offset(s)) < 0)
+ return ret;
+
s->cur_chan = 0;
s->bitshift = 0;
More information about the ffmpeg-cvslog
mailing list