Browse Source

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>
tags/n4.3
Michael Niedermayer 6 years ago
parent
commit
22bec0d33f
2 changed files with 6 additions and 1 deletions
  1. +5
    -1
      libavcodec/h2645_parse.c
  2. +1
    -0
      libavcodec/h2645_parse.h

+ 5
- 1
libavcodec/h2645_parse.c View File

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



+ 1
- 0
libavcodec/h2645_parse.h View File

@@ -78,6 +78,7 @@ typedef struct H2645Packet {
H2645RBSP rbsp;
int nb_nals;
int nals_allocated;
unsigned nal_buffer_size;
} H2645Packet;

/**


Loading…
Cancel
Save