resolve even more null derefs from string parsing in vkbd

CID 1132747
This commit is contained in:
Mike Blumenkrantz 2018-02-06 11:16:20 -05:00
parent aba428d86c
commit 74dd3ad387
1 changed files with 6 additions and 9 deletions

View File

@ -1032,7 +1032,7 @@ _e_kbd_int_layout_build(E_Kbd_Int *ki)
if (icon) if (icon)
{ {
char buf[PATH_MAX], *p; char buf[PATH_MAX];
o2 = e_icon_add(e_comp->evas); o2 = e_icon_add(e_comp->evas);
e_icon_fill_inside_set(o2, 1); e_icon_fill_inside_set(o2, 1);
@ -1042,8 +1042,7 @@ _e_kbd_int_layout_build(E_Kbd_Int *ki)
evas_object_show(o2); evas_object_show(o2);
snprintf(buf, sizeof(buf), "%s/%s", ki->layout.directory, icon); snprintf(buf, sizeof(buf), "%s/%s", ki->layout.directory, icon);
p = strrchr(icon, '.'); if (eina_str_has_extension(icon, ".edj")) e_icon_file_edje_set(o2, buf, "icon");
if (!strcmp(p, ".edj")) e_icon_file_edje_set(o2, buf, "icon");
else e_icon_file_set(o2, buf); else e_icon_file_set(o2, buf);
} }
evas_object_grid_pack(ki->layout_obj, o, evas_object_grid_pack(ki->layout_obj, o,
@ -1101,7 +1100,7 @@ _e_kbd_int_layouts_list_update(E_Kbd_Int *ki)
{ {
Eina_List *files; Eina_List *files;
Eina_List *l; Eina_List *l;
char buf[PATH_MAX], *p, *file, *path; char buf[PATH_MAX], *file, *path;
const char *fl; const char *fl;
Eina_List *kbs = NULL, *layouts = NULL; Eina_List *kbs = NULL, *layouts = NULL;
int ok; int ok;
@ -1117,8 +1116,7 @@ _e_kbd_int_layouts_list_update(E_Kbd_Int *ki)
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)
{ {
p = strrchr(file, '.'); if (eina_str_has_extension(file, ".kbd"))
if ((p) && (!strcmp(p, ".kbd")))
{ {
if (eina_strlcpy(buf + len, file, sizeof(buf) - len) >= if (eina_strlcpy(buf + len, file, sizeof(buf) - len) >=
sizeof(buf) - len) sizeof(buf) - len)
@ -1138,8 +1136,7 @@ _e_kbd_int_layouts_list_update(E_Kbd_Int *ki)
EINA_LIST_FREE(files, file) EINA_LIST_FREE(files, file)
{ {
p = strrchr(file, '.'); if (eina_str_has_extension(file, ".kbd"))
if ((p) && (!strcmp(p, ".kbd")))
{ {
ok = 1; ok = 1;
EINA_LIST_FOREACH(kbs, l, fl) EINA_LIST_FOREACH(kbs, l, fl)
@ -1177,7 +1174,7 @@ _e_kbd_int_layouts_list_update(E_Kbd_Int *ki)
s = strdup(ecore_file_file_get(kil->path)); s = strdup(ecore_file_file_get(kil->path));
if (s) if (s)
{ {
p = strrchr(s, '.'); char *p = strrchr(s, '.');
if (p) *p = 0; if (p) *p = 0;
kil->name = eina_stringshare_add(s); kil->name = eina_stringshare_add(s);
free(s); free(s);