Browse Source

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 380659604f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n3.2.8
Michael Niedermayer 8 years ago
parent
commit
2cfabd8ce7
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      libavcodec/shorten.c

+ 7
- 6
libavcodec/shorten.c View File

@@ -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;



Loading…
Cancel
Save