From 01b5350bdcbe5c26f94f5fff9d72da955f56d7b3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 5 Nov 2019 18:31:41 +0100 Subject: [PATCH] Fix segfault in set_mode best is NULL prior to being assigned to a mode. Closes: https://github.com/swaywm/sway/issues/4705 Fixes: f33dcd4c604f ("Prefer higher refresh rate default modes") --- sway/config/output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sway/config/output.c b/sway/config/output.c index 6c716ccb..a30d7954 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -222,7 +222,9 @@ static bool set_mode(struct wlr_output *output, int width, int height, best = mode; break; } - best = mode->refresh > best->refresh ? mode : best; + if (best == NULL || mode->refresh > best->refresh) { + best = mode; + } } } if (!best) {