summaryrefslogtreecommitdiffstats
path: root/demux/demux_lavf.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-16 18:11:00 +0200
committerwm4 <wm4@nowhere>2014-09-16 18:11:00 +0200
commitcaaeb15318dbdd38344f15a8919540f188de5c46 (patch)
treee0416e67067fcbb4485d96deaacd7dd55f55a51e /demux/demux_lavf.c
parent26e0cce9699e672b3d56c3b184a662955c4815bc (diff)
downloadmpv-caaeb15318dbdd38344f15a8919540f188de5c46.tar.bz2
mpv-caaeb15318dbdd38344f15a8919540f188de5c46.tar.xz
demux: gracefully handle packet allocation failures
Now the packet allocation functions can fail.
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r--demux/demux_lavf.c12
1 files changed, 9 insertions, 3 deletions
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);