matroska_parse_rm_audio: check for malloc failure

Fixes CID733712
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-10-20 16:55:45 +02:00
parent d7cabb3c7e
commit 1116491c53
1 changed files with 5 additions and 2 deletions

View File

@ -2043,8 +2043,11 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
}
while (track->audio.pkt_cnt) {
AVPacket *pkt = av_mallocz(sizeof(AVPacket));
av_new_packet(pkt, a);
AVPacket *pkt = NULL;
if (!(pkt = av_mallocz(sizeof(AVPacket))) || av_new_packet(pkt, a) < 0){
av_free(pkt);
return AVERROR(ENOMEM);
}
memcpy(pkt->data, track->audio.buf
+ a * (h*w / a - track->audio.pkt_cnt--), a);
pkt->pts = track->audio.buf_timecode;