From 893ea5e47bf343b72814eec9544d4c1ad409bfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Mon, 24 Jun 2024 14:45:13 +0200 Subject: [PATCH] player/playloop: fix null dereference if filter_root does not exist For example when `input-commands=drop-buffers` is added to the config. Add a check inside mp_filter_reset(). Found by OSS-Fuzz. --- filters/f_decoder_wrapper.c | 3 +-- filters/filter.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index a99c27b7af..47c230272b 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -1114,8 +1114,7 @@ static void public_f_reset(struct mp_filter *f) if (p->queue) { mp_async_queue_reset(p->queue); thread_lock(p); - if (p->dec_root_filter) - mp_filter_reset(p->dec_root_filter); + mp_filter_reset(p->dec_root_filter); mp_dispatch_interrupt(p->dec_dispatch); thread_unlock(p); mp_async_queue_resume(p->queue); diff --git a/filters/filter.c b/filters/filter.c index 1d13393194..688d40d8c8 100644 --- a/filters/filter.c +++ b/filters/filter.c @@ -592,6 +592,9 @@ static void reset_pin(struct mp_pin *p) void mp_filter_reset(struct mp_filter *filter) { + if (!filter) + return; + for (int n = 0; n < filter->in->num_children; n++) mp_filter_reset(filter->in->children[n]);