aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-09-10 21:10:16 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2017-09-17 12:21:32 +0200
commit2cfabd8ce7913dcf4d5413441d0fb5a02cd18884 (patch)
tree75a06e2274eb910605e4590be5f659bdcc187bbb /libavcodec
parent87ef295ddf53068a5bbfd2cd1c91a1b01b787ad7 (diff)
downloadffmpeg-2cfabd8ce7913dcf4d5413441d0fb5a02cd18884.tar.gz
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@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 380659604f2692b625928a3a76a1c046f473c9f6) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/shorten.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index a36a77210e..b56d205932 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -453,12 +453,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;
@@ -494,6 +488,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;