Merge commit '1551602b423755c4ed98c5b7b2c2d6504416726e' into release/2.4
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 18 Jan 2015 00:09:57 +0000 (01:09 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 18 Jan 2015 00:10:10 +0000 (01:10 +0100)
* commit '1551602b423755c4ed98c5b7b2c2d6504416726e':
  nutdec: check av_new_packet return value

Conflicts:
libavformat/nutdec.c

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

@@@ -1020,27 -847,12 +1019,28 @@@ static int decode_frame(NUTContext *nut
          return 1;
      }
  
-     if (av_new_packet(pkt, size + nut->header_len[header_idx]) < 0)
-         return AVERROR(ENOMEM);
+     ret = av_new_packet(pkt, size + nut->header_len[header_idx]);
+     if (ret < 0)
+         return ret;
      memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
      pkt->pos = avio_tell(bc); // FIXME
 -    avio_read(bc, pkt->data + nut->header_len[header_idx], size);
 +    if (stc->last_flags & FLAG_SM_DATA) {
 +        int sm_size;
 +        if (read_sm_data(s, bc, pkt, 0, pkt->pos + size) < 0)
 +            return AVERROR_INVALIDDATA;
 +        if (read_sm_data(s, bc, pkt, 1, pkt->pos + size) < 0)
 +            return AVERROR_INVALIDDATA;
 +        sm_size = avio_tell(bc) - pkt->pos;
 +        size      -= sm_size;
 +        pkt->size -= sm_size;
 +    }
 +
 +    ret = avio_read(bc, pkt->data + nut->header_len[header_idx], size);
 +    if (ret != size) {
 +        if (ret < 0)
 +            return ret;
 +    }
 +    av_shrink_packet(pkt, nut->header_len[header_idx] + ret);
  
      pkt->stream_index = stream_id;
      if (stc->last_flags & FLAG_KEY)