bench: Check for errors opening Compose file
authorBryce Harrington <bryce@bryceharrington.org>
Thu, 15 Sep 2016 21:12:38 +0000 (14:12 -0700)
committerRan Benita <ran234@gmail.com>
Fri, 16 Sep 2016 06:23:43 +0000 (09:23 +0300)
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>
bench/compose.c

index 267b757..04873a7 100644 (file)
@@ -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);