=== modified file 'driver-ti.c' --- driver-ti.c 2019-02-21 18:50:28 +0000 +++ driver-ti.c 2019-02-19 23:30:41 +0000 @@ -15,7 +15,6 @@ #endif #include -#include #include #include #include @@ -250,14 +249,10 @@ static bool try_load_terminfo_key(TermKeyTI *ti, const char *name, struct keyinfo *info) { - const char *value = NULL; - #ifdef HAVE_UNIBILIUM - if(ti->unibi) - value = unibi_get_str_by_name(ti->unibi, name); + const char *value = unibi_get_str_by_name(ti->unibi, name); #else - if(ti->term) - value = tigetstr(name); + const char *value = tigetstr(name); #endif if(ti->tk->ti_getstr_hook) @@ -341,9 +336,7 @@ * time we want to use it */ #ifdef HAVE_UNIBILIUM - const char *keypad_xmit = unibi ? - unibi_get_str(unibi, unibi_keypad_xmit) : - NULL; + const char *keypad_xmit = unibi_get_str(unibi, unibi_keypad_xmit); #endif if(keypad_xmit) @@ -352,9 +345,7 @@ ti->start_string = NULL; #ifdef HAVE_UNIBILIUM - const char *keypad_local = unibi ? - unibi_get_str(unibi, unibi_keypad_local) : - NULL; + const char *keypad_local = unibi_get_str(unibi, unibi_keypad_local); #endif if(keypad_local) @@ -363,14 +354,10 @@ ti->stop_string = NULL; #ifdef HAVE_UNIBILIUM - if(unibi) - unibi_destroy(unibi); - + unibi_destroy(unibi); ti->unibi = NULL; #else - if(ti->term) - free(ti->term); - + free(ti->term); ti->term = NULL; #endif @@ -392,29 +379,27 @@ #ifdef HAVE_UNIBILIUM ti->unibi = unibi_from_term(term); - int saved_errno = errno; - if(!ti->unibi && saved_errno != ENOENT) { - free(ti); - return NULL; - } - /* ti->unibi may be NULL if errno == ENOENT. That means the terminal wasn't - * known. Lets keep going because if we get getstr hook that might invent - * new strings for us - */ + if(!ti->unibi) + goto abort_free; #else { int err; - ti->term = NULL; - /* Have to cast away the const. But it's OK - we know terminfo won't really * modify term */ - if(setupterm((char*)term, 1, &err) == OK) - ti->term = strdup(term); + if(setupterm((char*)term, 1, &err) != OK) + goto abort_free; + + ti->term = strdup(term); } #endif return ti; + +abort_free: + free(ti); + + return NULL; } static int start_driver(TermKey *tk, void *info)