From 243c9409c99c7f4054427a1afc6b6f97b3873e18 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Wed, 17 Apr 2013 13:29:26 +0100 Subject: [PATCH] Add some additional error trapping for keyboard info initialization. Signed-off-by: Chris Michael --- src/bin/e_comp_wl.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index f3d8a0e..bb8a654 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -801,7 +801,11 @@ _e_comp_wl_input_keyboard_info_get(struct xkb_keymap *keymap) if (!(info = E_NEW(E_Wayland_Keyboard_Info, 1))) return NULL; - info->keymap = xkb_map_ref(keymap); + if (!(info->keymap = xkb_map_ref(keymap))) + { + E_FREE(info); + return NULL; + } /* init modifiers */ info->mod_shift = xkb_map_mod_get_index(keymap, XKB_MOD_NAME_SHIFT); @@ -813,7 +817,9 @@ _e_comp_wl_input_keyboard_info_get(struct xkb_keymap *keymap) /* try to get a string of this keymap */ if (!(tmp = xkb_map_get_as_string(keymap))) { - printf("Could not map get as string\n"); + printf("Could not get keymap as string\n"); + E_FREE(info); + return NULL; } info->size = strlen(tmp) + 1; @@ -823,6 +829,8 @@ _e_comp_wl_input_keyboard_info_get(struct xkb_keymap *keymap) if (info->fd < 0) { printf("Could not create keymap fd\n"); + E_FREE(info); + return NULL; } info->area = @@ -830,8 +838,11 @@ _e_comp_wl_input_keyboard_info_get(struct xkb_keymap *keymap) /* TODO: error check mmap */ - strcpy(info->area, tmp); - free(tmp); + if ((info->area) && (tmp)) + { + strcpy(info->area, tmp); + free(tmp); + } return info; } -- 2.7.4