summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorMikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-23 14:25:58 +0100
committerMikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-03-23 14:37:56 +0100
commit12c8d40d8996dd420eb723d0b35ff5034a15a9b1 (patch)
treec3ede8bd7328a8445667a255631fd76c7eb65f82 /main.c
parentf5bb2b8766f3410e131fffe284b239239732f1d9 (diff)
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
Diffstat (limited to 'main.c')
-rw-r--r--main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.c b/main.c
index f2015a0..3f0fc86 100644
--- a/main.c
+++ b/main.c
@@ -31,7 +31,9 @@ void sway_terminate(int exit_code) {
window_teardown(window);
}
list_free(surfaces);
- registry_teardown(registry);
+ if (registry) {
+ registry_teardown(registry);
+ }
exit(exit_code);
}
@@ -292,6 +294,10 @@ int main(int argc, char **argv) {
surfaces = create_list();
registry = registry_poll();
+ if (!registry) {
+ sway_abort("Unable to connect to wayland compositor");
+ }
+
if (!registry->swaylock) {
sway_abort("swaylock requires the compositor to support the swaylock extension.");
}