Merge commit 'a8765852158ecb2ae34895fa35ff51dc95c186f9'

* commit 'a8765852158ecb2ae34895fa35ff51dc95c186f9':
  movenc: Check memory allocations

Conflicts:
	libavformat/movenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-02-17 21:50:08 +01:00
commit 80c5dc5610
1 changed files with 10 additions and 0 deletions

View File

@ -1824,6 +1824,8 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) { if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) {
stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */ stts_entries = av_malloc(sizeof(*stts_entries)); /* one entry */
if (!stts_entries)
return AVERROR(ENOMEM);
stts_entries[0].count = track->sample_count; stts_entries[0].count = track->sample_count;
stts_entries[0].duration = 1; stts_entries[0].duration = 1;
entries = 1; entries = 1;
@ -1831,6 +1833,8 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
stts_entries = track->entry ? stts_entries = track->entry ?
av_malloc_array(track->entry, sizeof(*stts_entries)) : /* worst case */ av_malloc_array(track->entry, sizeof(*stts_entries)) : /* worst case */
NULL; NULL;
if (!stts_entries)
return AVERROR(ENOMEM);
for (i = 0; i < track->entry; i++) { for (i = 0; i < track->entry; i++) {
int duration = get_cluster_duration(track, i); int duration = get_cluster_duration(track, i);
if (i && duration == stts_entries[entries].duration) { if (i && duration == stts_entries[entries].duration) {
@ -4159,6 +4163,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
if (trk->vos_len == 0 && enc->extradata_size > 0 && !TAG_IS_AVCI(trk->tag)) { if (trk->vos_len == 0 && enc->extradata_size > 0 && !TAG_IS_AVCI(trk->tag)) {
trk->vos_len = enc->extradata_size; trk->vos_len = enc->extradata_size;
trk->vos_data = av_malloc(trk->vos_len); trk->vos_data = av_malloc(trk->vos_len);
if (!trk->vos_data) {
ret = AVERROR(ENOMEM);
goto err;
}
memcpy(trk->vos_data, enc->extradata, trk->vos_len); memcpy(trk->vos_data, enc->extradata, trk->vos_len);
} }
@ -4938,6 +4946,8 @@ static int mov_write_header(AVFormatContext *s)
else if (!TAG_IS_AVCI(track->tag)){ else if (!TAG_IS_AVCI(track->tag)){
track->vos_len = st->codec->extradata_size; track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len); track->vos_data = av_malloc(track->vos_len);
if (!track->vos_data)
goto error;
memcpy(track->vos_data, st->codec->extradata, track->vos_len); memcpy(track->vos_data, st->codec->extradata, track->vos_len);
} }
} }