diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-18 14:53:24 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-18 14:53:24 -0500 |
commit | c838679393440680c9337a745be4f659ac7349c2 (patch) | |
tree | 38f97a9c5ebc54ce7903af29cd700476c901dec7 | |
parent | 20327d82cb4f2f56cf0822554aebe19ed32fd623 (diff) | |
download | wlroots-c838679393440680c9337a745be4f659ac7349c2.tar.xz |
fix memory leaks
-rw-r--r-- | rootston/keyboard.c | 1 | ||||
-rw-r--r-- | types/wlr_keyboard.c | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/rootston/keyboard.c b/rootston/keyboard.c index 758a49fb..16071c0c 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -364,6 +364,7 @@ struct roots_keyboard *roots_keyboard_create(struct wlr_input_device *device, } wlr_keyboard_set_keymap(device->keyboard, keymap); + xkb_keymap_unref(keymap); xkb_context_unref(context); int repeat_rate = (config->repeat_rate > 0) ? config->repeat_rate : 25; diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 1c35825e..5ec8c043 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -118,7 +118,7 @@ void wlr_keyboard_destroy(struct wlr_keyboard *kb) { wl_list_remove(&kb->events.key.listener_list); } xkb_state_unref(kb->xkb_state); - xkb_map_unref(kb->keymap); + xkb_keymap_unref(kb->keymap); close(kb->keymap_fd); free(kb); } @@ -136,6 +136,11 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb, } xkb_keymap_ref(keymap); kb->keymap = keymap; + + if (kb->xkb_state) { + xkb_state_unref(kb->xkb_state); + } + kb->xkb_state = xkb_state_new(kb->keymap); if (kb->xkb_state == NULL) { wlr_log(L_ERROR, "Failed to create XKB state"); |