devilhorns pushed a commit to branch master.

commit 243c9409c99c7f4054427a1afc6b6f97b3873e18
Author: Chris Michael <[email protected]>
Date:   Wed Apr 17 13:29:26 2013 +0100

    Add some additional error trapping for keyboard info initialization.
    
    Signed-off-by: Chris Michael <[email protected]>
---
 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;
 }

-- 

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

Reply via email to