summaryrefslogtreecommitdiffstats
path: root/libavcodec/h2645_parse.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-10-05 18:19:39 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-10-06 20:00:59 +0200
commit22bec0d33f4231487547581a1f77e2e8e6eade88 (patch)
tree34c7063038782f86c104096068266291a5d76765 /libavcodec/h2645_parse.c
parente3650dcfc9cde6ceccf7bbc225962da196e2a386 (diff)
downloadffmpeg-streaming-22bec0d33f4231487547581a1f77e2e8e6eade88.zip
ffmpeg-streaming-22bec0d33f4231487547581a1f77e2e8e6eade88.tar.gz
avcodec/h2645_parse: Use av_fast_realloc() for nals array
Fixes: Timeout (17sec ->281ms) Fixes: 17833/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5638346914660352 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/h2645_parse.c')
-rw-r--r--libavcodec/h2645_parse.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index ef6a6b4..b1dba3d 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -455,8 +455,12 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
if (pkt->nals_allocated < pkt->nb_nals + 1) {
int new_size = pkt->nals_allocated + 1;
- void *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*pkt->nals));
+ void *tmp;
+ if (new_size >= INT_MAX / sizeof(*pkt->nals))
+ return AVERROR(ENOMEM);
+
+ tmp = av_fast_realloc(pkt->nals, &pkt->nal_buffer_size, new_size * sizeof(*pkt->nals));
if (!tmp)
return AVERROR(ENOMEM);
OpenPOWER on IntegriCloud