From ddde118c69feb994fea812fb03f5dc78f3348ae1 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Thu, 1 Aug 2019 21:23:56 +0100 Subject: [PATCH] core: check if a chosen backend is available Error out instead of segfaulting when the chosen backend is not available. Fixes #210 Signed-off-by: Yuxuan Shui --- src/compton.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compton.c b/src/compton.c index 38504a5..7d34829 100644 --- a/src/compton.c +++ b/src/compton.c @@ -258,8 +258,8 @@ static bool run_fade(session_t *ps, struct managed_win **_w, long steps) { } } - // Note even if opacity == opacity_target here, we still want to run preprocess one - // last time to finish state transition. So return true in that case too. + // Note even if opacity == opacity_target here, we still want to run preprocess + // one last time to finish state transition. So return true in that case too. return true; } @@ -723,7 +723,13 @@ static bool initialize_backend(session_t *ps) { if (ps->o.experimental_backends) { assert(!ps->backend_data); // Reinitialize win_data - ps->backend_data = backend_list[ps->o.backend]->init(ps); + if (backend_list[ps->o.backend]) { + ps->backend_data = backend_list[ps->o.backend]->init(ps); + } else { + log_error("Backend \"%s\" is not available as part of the " + "experimental backends.", + BACKEND_STRS[ps->o.backend]); + } if (!ps->backend_data) { log_fatal("Failed to initialize backend, aborting..."); quit_compton(ps);