From 39adaf3dcc3a0e03df8048d93324940b5f69df51 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 25 Jan 2017 08:32:35 +0100 Subject: vf_lavfi: don't crash with VOs without hardware decoding support When playing with VOs which do not provide mp_hwdec_ctx, vf->hwdec_devs will remain NULL. This would make it crash on hwdec_devices_get_first(), even if no hardware decoding or filters using hardware decoding were involved. Fixes #4064. --- video/filter/vf_lavfi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c index e28d7fbb6f..d79bfd4011 100644 --- a/video/filter/vf_lavfi.c +++ b/video/filter/vf_lavfi.c @@ -174,11 +174,13 @@ static bool recreate_graph(struct vf_instance *vf, struct mp_image_params *fmt) if (graph_parse(graph, p->cfg_graph, inputs, outputs, NULL) < 0) goto error; - struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(vf->hwdec_devs); - for (int n = 0; n < graph->nb_filters; n++) { - AVFilterContext *filter = graph->filters[n]; - if (hwdec && hwdec->av_device_ref) - filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref); + if (vf->hwdec_devs) { + struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(vf->hwdec_devs); + for (int n = 0; n < graph->nb_filters; n++) { + AVFilterContext *filter = graph->filters[n]; + if (hwdec && hwdec->av_device_ref) + filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref); + } } if (avfilter_graph_config(graph, NULL) < 0) -- cgit v1.2.3