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_tv.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'demux/demux_tv.c') diff --git a/demux/demux_tv.c b/demux/demux_tv.c index f0ee9793e3..fe7584a387 100644 --- a/demux/demux_tv.c +++ b/demux/demux_tv.c @@ -204,26 +204,30 @@ static int demux_tv_fill_buffer(demuxer_t *demux) if (want_audio && tvh->tv_param->audio && tvh->functions->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) - { + { len = tvh->functions->get_audio_framesize(tvh->priv); dp=new_demux_packet(len); - dp->keyframe = true; - dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len); - demux_add_packet(want_audio, dp); + if (dp) { + dp->keyframe = true; + dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len); + demux_add_packet(want_audio, dp); } + } /* ================== ADD VIDEO PACKET =================== */ if (want_video && tvh->functions->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE) - { - len = tvh->functions->get_video_framesize(tvh->priv); + { + len = tvh->functions->get_video_framesize(tvh->priv); dp=new_demux_packet(len); - dp->keyframe = true; - dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len); - demux_add_packet(want_video, dp); - } + if (dp) { + dp->keyframe = true; + dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len); + demux_add_packet(want_video, dp); + } + } if (tvh->tv_param->scan) tv_scan(tvh); return 1; -- cgit v1.2.3