context: Don't fail to create the context if HOME isn't available
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Sun, 20 Oct 2019 19:06:19 +0000 (19:06 +0000)
committerRan Benita <ran@unusedvar.com>
Sun, 20 Oct 2019 20:00:30 +0000 (23:00 +0300)
E.g. when Mutter has CAP_SYS_NICE and thus secure_getenv returns NULL.

Fixes https://bugs.archlinux.org/task/64191

[ran: changed to ignore error]
Signed-off-by: Ran Benita <ran@unusedvar.com>
src/context.c

index f43ee0a..f426751 100644 (file)
@@ -81,13 +81,13 @@ xkb_context_include_path_append_default(struct xkb_context *ctx)
     int ret = 0;
 
     home = secure_getenv("HOME");
-    if (!home)
-        return ret;
-    err = asprintf(&user_path, "%s/.xkb", home);
-    if (err <= 0)
-        return ret;
-    ret |= xkb_context_include_path_append(ctx, user_path);
-    free(user_path);
+    if (home != NULL) {
+        err = asprintf(&user_path, "%s/.xkb", home);
+        if (err >= 0) {
+            ret |= xkb_context_include_path_append(ctx, user_path);
+            free(user_path);
+        }
+    }
 
     root = secure_getenv("XKB_CONFIG_ROOT");
     if (root != NULL)