From 30e9e2dc9f6d83418a00f8b1a8bd028476d80bb8 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 10 Nov 2019 05:07:03 +0000 Subject: [PATCH] core: check experimental_backend before accessing backend_list backend_list[backend] is only guaranteed to be non-NULL if experimental backends are used. Fixes #258 Signed-off-by: Yuxuan Shui --- src/picom.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/picom.c b/src/picom.c index f48538a..0f8297d 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1161,9 +1161,15 @@ xcb_window_t session_get_target_window(session_t *ps) { } static inline uint8_t session_redirection_mode(session_t *ps) { - if (ps->o.debug_mode || !backend_list[ps->o.backend]->present) { - // If the backend is not rendering to the screen, or if the backend - // doesn't render anything, we don't need to take over the screen. + if (ps->o.debug_mode) { + // If the backend is not rendering to the screen, we don't need to + // take over the screen. + assert(ps->o.experimental_backends); + return XCB_COMPOSITE_REDIRECT_AUTOMATIC; + } + if (ps->o.experimental_backends && !backend_list[ps->o.backend]->present) { + // if the backend doesn't render anything, we don't need to take over the + // screen. return XCB_COMPOSITE_REDIRECT_AUTOMATIC; } return XCB_COMPOSITE_REDIRECT_MANUAL;