Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
zwp_virtual-keyboard: fix mmap error handling
Browse files Browse the repository at this point in the history
If mmap fails, it will return MAP_FAILED not NULL. Since the error
handling was incorrectly checking for NULL, MAP_FAILED was being passed
to xkb_keymap_new_from_string, on mmap failure, causing a segfault.
This just fixes the error checking.
  • Loading branch information
RedSoxFan authored and emersion committed May 31, 2019
1 parent a5e32f6 commit 6dfe238
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion types/wlr_virtual_keyboard_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void virtual_keyboard_keymap(struct wl_client *client,
goto context_fail;
}
void *data = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
if (!data) {
if (data == MAP_FAILED) {
goto fd_fail;
}
struct xkb_keymap *keymap = xkb_keymap_new_from_string(context, data,
Expand Down

0 comments on commit 6dfe238

Please sign in to comment.