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>
master
Bryce Harrington 2016-09-15 14:12:38 -07:00 committed by Ran Benita
parent 599fd9ba39
commit ea9a5bcfd7
1 changed files with 6 additions and 0 deletions

View File

@ -45,6 +45,12 @@ main(void)
path = test_get_path("compose/en_US.UTF-8/Compose"); path = test_get_path("compose/en_US.UTF-8/Compose");
file = fopen(path, "r"); 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_level(ctx, XKB_LOG_LEVEL_CRITICAL);
xkb_context_set_log_verbosity(ctx, 0); xkb_context_set_log_verbosity(ctx, 0);