Commit 6db511a7 authored by Dale Curtis's avatar Dale Curtis Committed by Michael Niedermayer

avformat/mov: Increment stsd_count while processing stsd data; avoids leaks.

In the event of ff_mov_read_stsd_entries() failure, sc->stsd_count
is not updated, even if the function allocates extradata memory.
Instead update the sc->stsd_count as entries are parsed so that
mov_read_close() can do the right thing.
Signed-off-by: 's avatarDale Curtis <dalecurtis@chromium.org>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 3d5822d9
...@@ -2464,8 +2464,10 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) ...@@ -2464,8 +2464,10 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
} }
if (mov_skip_multiple_stsd(c, pb, st->codecpar->codec_tag, format, if (mov_skip_multiple_stsd(c, pb, st->codecpar->codec_tag, format,
size - (avio_tell(pb) - start_pos))) size - (avio_tell(pb) - start_pos))) {
sc->stsd_count++;
continue; continue;
}
sc->pseudo_stream_id = st->codecpar->codec_tag ? -1 : pseudo_stream_id; sc->pseudo_stream_id = st->codecpar->codec_tag ? -1 : pseudo_stream_id;
sc->dref_id= dref_id; sc->dref_id= dref_id;
...@@ -2517,6 +2519,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries) ...@@ -2517,6 +2519,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
av_freep(&st->codecpar->extradata); av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0; st->codecpar->extradata_size = 0;
} }
sc->stsd_count++;
} }
if (pb->eof_reached) if (pb->eof_reached)
...@@ -2566,8 +2569,6 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom) ...@@ -2566,8 +2569,6 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
if (ret < 0) if (ret < 0)
goto fail; goto fail;
sc->stsd_count = entries;
/* Restore back the primary extradata. */ /* Restore back the primary extradata. */
av_freep(&st->codecpar->extradata); av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = sc->extradata_size[0]; st->codecpar->extradata_size = sc->extradata_size[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment