summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-23 14:25:58 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-23 14:37:56 +0100
commita8f989c6516e52ac6fe5380f39c94e470b7892e8 (patch)
tree60f54a108cdb6ff37a685b1f18c19604d3c93fca
parentMerge pull request #530 from mikkeloscar/swaybar-kill-on-sway-crash (diff)
downloadsway-a8f989c6516e52ac6fe5380f39c94e470b7892e8.tar.gz
sway-a8f989c6516e52ac6fe5380f39c94e470b7892e8.tar.zst
sway-a8f989c6516e52ac6fe5380f39c94e470b7892e8.zip
swaylock: Fix crash when unable to connect to wl
Prevent swaylock from crashing when it can't connect to wayland for whatever reason. i.e. XDG_RUNTIME_DIR not set. Fix #534
-rw-r--r--swaylock/main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/swaylock/main.c b/swaylock/main.c
index f2015a05..3f0fc867 100644
--- a/swaylock/main.c
+++ b/swaylock/main.c
@@ -31,7 +31,9 @@ void sway_terminate(int exit_code) {
31 window_teardown(window); 31 window_teardown(window);
32 } 32 }
33 list_free(surfaces); 33 list_free(surfaces);
34 registry_teardown(registry); 34 if (registry) {
35 registry_teardown(registry);
36 }
35 exit(exit_code); 37 exit(exit_code);
36} 38}
37 39
@@ -292,6 +294,10 @@ int main(int argc, char **argv) {
292 surfaces = create_list(); 294 surfaces = create_list();
293 registry = registry_poll(); 295 registry = registry_poll();
294 296
297 if (!registry) {
298 sway_abort("Unable to connect to wayland compositor");
299 }
300
295 if (!registry->swaylock) { 301 if (!registry->swaylock) {
296 sway_abort("swaylock requires the compositor to support the swaylock extension."); 302 sway_abort("swaylock requires the compositor to support the swaylock extension.");
297 } 303 }