diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-23 13:45:30 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-23 13:45:30 +0100 |
commit | 426ab803cb62e47e1040ea9bcbfae0749c014eb0 (patch) | |
tree | 127dfeb5391bb5484584d4733b13cdd5fe030f6e /src/gui/gui-keyboard.c | |
parent | 70cfce2d2c728842a43f1a2777a08571885b8001 (diff) | |
download | weechat-426ab803cb62e47e1040ea9bcbfae0749c014eb0.zip |
Test return code of some malloc/strdup
Diffstat (limited to 'src/gui/gui-keyboard.c')
-rw-r--r-- | src/gui/gui-keyboard.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index eea3e0382..f5dce6ec6 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -179,7 +179,11 @@ gui_keyboard_get_expanded_name (const char *key) { char *result; - if ((result = malloc ((strlen (key) * 5) + 1))) + if (!key) + return NULL; + + result = malloc ((strlen (key) * 5) + 1); + if (result) { result[0] = '\0'; while (key[0]) @@ -206,9 +210,7 @@ gui_keyboard_get_expanded_name (const char *key) } } } - else - return NULL; - + return result; } @@ -354,7 +356,7 @@ gui_keyboard_search_part (struct t_gui_buffer *buffer, const char *key) for (ptr_key = (buffer) ? buffer->keys : gui_keys; ptr_key; ptr_key = ptr_key->next_key) { - if (gui_keyboard_cmp (ptr_key->key, key) == 0) + if (ptr_key->key && (gui_keyboard_cmp (ptr_key->key, key) == 0)) return ptr_key; } |