summaryrefslogtreecommitdiff
path: root/src/lib/ecore_wl2/ecore_wl2_input.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2018-03-07 09:50:58 -0500
committerChris Michael <cp.michael@samsung.com>2018-03-07 09:50:58 -0500
commit59a689faa47b681e5b7005715dc02c5957bb60cc (patch)
tree75f580a7c33d1d676b8b38e87fd7217cea735e78 /src/lib/ecore_wl2/ecore_wl2_input.c
parenta1bb9b313f008f65b06319a1bede1f175c29d3da (diff)
ecore-wl2: Check for valid string before passing to strlen()
As strlen() cannot accept NULL (segfaults), we should check for valid key, keyname, and compose strings here before passing to strlen(). @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wl2/ecore_wl2_input.c')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_input.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c
index c252593350..3c8c3d4183 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -637,12 +637,11 @@ _ecore_wl2_input_key_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, xkb_
637 _ecore_wl2_input_key_translate(sym, input->keyboard.modifiers, 637 _ecore_wl2_input_key_translate(sym, input->keyboard.modifiers,
638 compose, sizeof(compose)); 638 compose, sizeof(compose));
639 639
640 name_len = strlen(keyname); 640 name_len = (keyname) ? strlen(keyname) : 0;
641 key_len = strlen(key); 641 key_len = (key) ? strlen(key) : 0;
642 comp_len = strlen(compose); 642 comp_len = (compose) ? strlen(compose) : 0;
643 643
644 ev = calloc(1, sizeof(Ecore_Event_Key) + key_len + name_len + 644 ev = calloc(1, sizeof(Ecore_Event_Key) + key_len + name_len + comp_len + 3);
645 ((compose[0] != '\0') ? comp_len : 0) + 3);
646 if (!ev) return; 645 if (!ev) return;
647 646
648 ev->keyname = (char *)(ev + 1); 647 ev->keyname = (char *)(ev + 1);