mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-03 05:10:03 +02:00
movenc: Check memory allocations
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
This commit is contained in:
parent
da7e31a240
commit
a876585215
@ -1167,6 +1167,8 @@ static int mov_write_ctts_tag(AVIOContext *pb, MOVTrack *track)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
ctts_entries = av_malloc((track->entry + 1) * sizeof(*ctts_entries)); /* worst case */
|
ctts_entries = av_malloc((track->entry + 1) * sizeof(*ctts_entries)); /* worst case */
|
||||||
|
if (!ctts_entries)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
ctts_entries[0].count = 1;
|
ctts_entries[0].count = 1;
|
||||||
ctts_entries[0].duration = track->cluster[0].cts;
|
ctts_entries[0].duration = track->cluster[0].cts;
|
||||||
for (i = 1; i < track->entry; i++) {
|
for (i = 1; i < track->entry; i++) {
|
||||||
@ -1202,6 +1204,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;
|
||||||
@ -1209,6 +1213,8 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
|
|||||||
stts_entries = track->entry ?
|
stts_entries = track->entry ?
|
||||||
av_malloc(track->entry * sizeof(*stts_entries)) : /* worst case */
|
av_malloc(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) {
|
||||||
@ -3282,6 +3288,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
if (trk->vos_len == 0 && enc->extradata_size > 0) {
|
if (trk->vos_len == 0 && enc->extradata_size > 0) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3829,6 +3839,8 @@ static int mov_write_header(AVFormatContext *s)
|
|||||||
else {
|
else {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user