aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2016-06-29 12:03:59 -0400
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-06-29 15:25:42 -0400
commit029cf99c5166b36f33381cd8ebfa5f1f1f463d1f (patch)
tree2e54960a383a43f257a61356c8fd3bcb46cd94a0 /libavformat
parent6c445990e64124ad64c79423dfd3764520648c89 (diff)
downloadffmpeg-029cf99c5166b36f33381cd8ebfa5f1f1f463d1f.tar.gz
mov: Save number of stsd elements after stream extradata allocation
Avoid freeing an unallocated array in mov_read_close() in case of a malloc failure. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/mov.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index fe1f264463..0cb3271d44 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1883,7 +1883,7 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
- int ret;
+ int ret, entries;
if (c->fc->nb_streams < 1)
return 0;
@@ -1892,13 +1892,14 @@ static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
- sc->stsd_count = avio_rb32(pb); /* entries */
+ entries = avio_rb32(pb);
/* Prepare space for hosting multiple extradata. */
- sc->extradata = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata));
+ sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata));
if (!sc->extradata)
return AVERROR(ENOMEM);
+ sc->stsd_count = entries;
sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(sc->extradata_size));
if (!sc->extradata_size)
return AVERROR(ENOMEM);