From caaeb15318dbdd38344f15a8919540f188de5c46 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 16 Sep 2014 18:11:00 +0200 Subject: demux: gracefully handle packet allocation failures Now the packet allocation functions can fail. --- demux/demux_lavf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'demux/demux_lavf.c') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index ce945a2c4b..750f0f09f3 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -479,9 +479,11 @@ static void handle_stream(demuxer_t *demuxer, int i) if (st->disposition & AV_DISPOSITION_ATTACHED_PIC) { sh->attached_picture = new_demux_packet_from(st->attached_pic.data, st->attached_pic.size); - sh->attached_picture->pts = 0; - talloc_steal(sh, sh->attached_picture); - sh->attached_picture->keyframe = true; + if (sh->attached_picture) { + sh->attached_picture->pts = 0; + talloc_steal(sh, sh->attached_picture); + sh->attached_picture->keyframe = true; + } } sh->format = codec->codec_tag; @@ -820,6 +822,10 @@ static int demux_lavf_fill_buffer(demuxer_t *demux) } struct demux_packet *dp = new_demux_packet_from_avpacket(pkt); + if (!dp) { + av_free_packet(pkt); + return 1; + } if (pkt->pts != AV_NOPTS_VALUE) dp->pts = pkt->pts * av_q2d(st->time_base); -- cgit v1.2.3