From c73a40555f41ad765c10ea5912525c56770e71d1 Mon Sep 17 00:00:00 2001 From: minus Date: Sat, 14 Jul 2018 00:01:43 +0200 Subject: [PATCH] swaybar/bg: Fix crash on DPMS off When turning off displays via DPMS, swaybar and swaybg still tried to render, but did not get a valid buffer, causing them to crash. --- swaybar/render.c | 3 +++ swaybg/main.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/swaybar/render.c b/swaybar/render.c index 2ebd338e..909b56f4 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -503,6 +503,9 @@ void render_frame(struct swaybar *bar, struct swaybar_output *output) { output->buffers, output->width * output->scale, output->height * output->scale); + if (!output->current_buffer) { + return; + } cairo_t *shm = output->current_buffer->cairo; cairo_save(shm); diff --git a/swaybg/main.c b/swaybg/main.c index 1796b245..f8e7e7ef 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -68,6 +68,9 @@ static void render_frame(struct swaybg_state *state) { buffer_height = state->height * state->scale; state->current_buffer = get_next_buffer(state->shm, state->buffers, buffer_width, buffer_height); + if (!state->current_buffer) { + return; + } cairo_t *cairo = state->current_buffer->cairo; if (state->args->mode == BACKGROUND_MODE_SOLID_COLOR) { cairo_set_source_u32(cairo, state->context.color);