Merge commit 'a8765852158ecb2ae34895fa35ff51dc95c186f9'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 17 Feb 2015 20:50:08 +0000 (21:50 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 17 Feb 2015 20:50:08 +0000 (21:50 +0100)
* commit 'a8765852158ecb2ae34895fa35ff51dc95c186f9':
  movenc: Check memory allocations

Conflicts:
libavformat/movenc.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/movenc.c

@@@ -1829,8 -1211,10 +1831,10 @@@ static int mov_write_stts_tag(AVIOConte
          entries = 1;
      } else {
          stts_entries = track->entry ?
 -                       av_malloc(track->entry * sizeof(*stts_entries)) : /* worst case */
 +                       av_malloc_array(track->entry, sizeof(*stts_entries)) : /* worst case */
                         NULL;
+         if (!stts_entries)
+             return AVERROR(ENOMEM);
          for (i = 0; i < track->entry; i++) {
              int duration = get_cluster_duration(track, i);
              if (i && duration == stts_entries[entries].duration) {
@@@ -4156,9 -3285,13 +4160,13 @@@ int ff_mov_write_packet(AVFormatContex
          samples_in_chunk = 1;
  
      /* copy extradata if it exists */
 -    if (trk->vos_len == 0 && enc->extradata_size > 0) {
 +    if (trk->vos_len == 0 && enc->extradata_size > 0 && !TAG_IS_AVCI(trk->tag)) {
          trk->vos_len  = enc->extradata_size;
          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);
      }
  
@@@ -4935,9 -3836,11 +4943,11 @@@ static int mov_write_header(AVFormatCon
          if (st->codec->extradata_size) {
              if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
                  mov_create_dvd_sub_decoder_specific_info(track, st);
 -            else {
 +            else if (!TAG_IS_AVCI(track->tag)){
                  track->vos_len  = st->codec->extradata_size;
                  track->vos_data = av_malloc(track->vos_len);
+                 if (!track->vos_data)
+                     goto error;
                  memcpy(track->vos_data, st->codec->extradata, track->vos_len);
              }
          }