Commit ea9a5bcfd7cd20a2ecce4f92915fd537a0a84d90

Bryce Harrington 2016-09-15T14:12:38

bench: Check for errors opening Compose file Otherwise it can segfault e.g. running ./compose inside the bench directory. Signed-off-by: Bryce Harrington <bryce@bryceharrington.org> Signed-off-by: Ran Benita <ran234@gmail.com>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/bench/compose.c b/bench/compose.c
index 267b757..04873a7 100644
--- a/bench/compose.c
+++ b/bench/compose.c
@@ -45,6 +45,12 @@ main(void)
 
     path = test_get_path("compose/en_US.UTF-8/Compose");
     file = fopen(path, "r");
+    if (file == NULL) {
+	    perror(path);
+	    free(path);
+	    xkb_context_unref(ctx);
+	    return -1;
+    }
 
     xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
     xkb_context_set_log_verbosity(ctx, 0);