aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-04-10 22:05:07 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-05 01:47:56 +0200
commit75df98c0a00aa664e8645a07b7f9ad6760ba6631 (patch)
tree450d60fdec4b2421eb92c930d4149e75e6713ef0
parentc540f6939de2ed1eff0f860b2534c8383b3c5e32 (diff)
downloadffmpeg-75df98c0a00aa664e8645a07b7f9ad6760ba6631.tar.gz
avcodec/cbs: Allocate more CodedBitstreamUnit at once in cbs_insert_unit()
Fixes: Timeout (85sec -> 0.5sec) Fixes: 20791/clusterfuzz-testcase-minimized-ffmpeg_BSF_AV1_FRAME_SPLIT_fuzzer-5659537719951360 Fixes: 21214/clusterfuzz-testcase-minimized-ffmpeg_BSF_MPEG2_METADATA_fuzzer-5165560875974656 Fixes: 21247/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-5715175257931776 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 49ba60fed04d7011c36bae378445ba93ccf983c2) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/cbs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 0ce66170ec..0a71385fa2 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -693,11 +693,11 @@ static int cbs_insert_unit(CodedBitstreamContext *ctx,
memmove(units + position + 1, units + position,
(frag->nb_units - position) * sizeof(*units));
} else {
- units = av_malloc_array(frag->nb_units + 1, sizeof(*units));
+ units = av_malloc_array(frag->nb_units*2 + 1, sizeof(*units));
if (!units)
return AVERROR(ENOMEM);
- ++frag->nb_units_allocated;
+ frag->nb_units_allocated = 2*frag->nb_units_allocated + 1;
if (position > 0)
memcpy(units, frag->units, position * sizeof(*units));