diff mbox

[FFmpeg-devel] Fix memory leak when reading DDTS box.

Message ID 20170815190844.112408-1-nbowe@google.com
State Accepted
Commit 4b54d5a721cc55288093417b098382bbb27a8d3f
Headers show

Commit Message

Niki Bowe Aug. 15, 2017, 7:08 p.m. UTC
---
 libavformat/mov.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Michael Niedermayer Aug. 16, 2017, 1:35 a.m. UTC | #1
On Tue, Aug 15, 2017 at 12:08:44PM -0700, Nikolas Bowe wrote:
> ---
>  libavformat/mov.c | 3 +++
>  1 file changed, 3 insertions(+)

applied

thx

[...]
diff mbox

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 63f84be782..c02caf6719 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -889,6 +889,7 @@  static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     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];
@@ -896,6 +897,7 @@  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 */
@@ -923,6 +925,7 @@  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;
 }