diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-06-14 21:18:23 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-06-22 13:14:52 +0200 |
commit | 9ce1eb5eb06825b1fbecbca632cb0c4786d2bd77 (patch) | |
tree | 10d1cdb91757b762714c69c923626f4085acdc81 /libavformat/mov.c | |
parent | 316a3e91bec1ef034401c65e32a2db804a84dbc5 (diff) | |
download | ffmpeg-9ce1eb5eb06825b1fbecbca632cb0c4786d2bd77.tar.gz |
avformat/mov: Avoid allocation when reading ddts atom
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index 833f3a8503..6b464a8f6e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -857,27 +857,20 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) { - const uint32_t ddts_size = 20; +#define DDTS_SIZE 20 + uint8_t buf[DDTS_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; AVStream *st = NULL; - uint8_t *buf = NULL; uint32_t frame_duration_code = 0; uint32_t channel_layout_code = 0; GetBitContext gb; int ret; - buf = av_malloc(ddts_size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!buf) { - return AVERROR(ENOMEM); - } - if ((ret = ffio_read_size(pb, buf, ddts_size)) < 0) { - av_free(buf); + if ((ret = ffio_read_size(pb, buf, DDTS_SIZE)) < 0) return ret; - } - init_get_bits(&gb, buf, 8*ddts_size); + init_get_bits(&gb, buf, 8 * DDTS_SIZE); if (c->fc->nb_streams < 1) { - av_free(buf); return 0; } st = c->fc->streams[c->fc->nb_streams-1]; @@ -885,7 +878,6 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->codecpar->sample_rate = get_bits_long(&gb, 32); if (st->codecpar->sample_rate <= 0) { av_log(c->fc, AV_LOG_ERROR, "Invalid sample rate %d\n", st->codecpar->sample_rate); - av_free(buf); return AVERROR_INVALIDDATA; } skip_bits_long(&gb, 32); /* max bitrate */ @@ -913,7 +905,6 @@ static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom) ((channel_layout_code & 0x8) ? AV_CH_LOW_FREQUENCY : 0); st->codecpar->channels = av_get_channel_layout_nb_channels(st->codecpar->channel_layout); - av_free(buf); return 0; } |