diff options
author | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-20 18:03:08 +0000 |
---|---|---|
committer | Paul LeoNerd Evans <leonerd@leonerd.org.uk> | 2012-01-20 18:03:08 +0000 |
commit | 229792aad759eb1bf8a67318e25baecc249273a8 (patch) | |
tree | ab0c856a5b96fe033defa233531fd3311f571c14 /termkey.c | |
parent | 08b7eaa5b72aa523c982358c6edc948fca40420b (diff) | |
download | termo-229792aad759eb1bf8a67318e25baecc249273a8.tar.gz termo-229792aad759eb1bf8a67318e25baecc249273a8.tar.xz termo-229792aad759eb1bf8a67318e25baecc249273a8.zip |
Handle realloc() failures when registering key names
Diffstat (limited to 'termkey.c')
-rw-r--r-- | termkey.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -239,7 +239,8 @@ static TermKey *termkey_new_full(int fd, int flags, size_t buffsize, int waittim tk->method.peekkey_mouse = &peekkey_mouse; for(i = 0; keynames[i].name; i++) - termkey_register_keyname(tk, keynames[i].sym, keynames[i].name); + if(termkey_register_keyname(tk, keynames[i].sym, keynames[i].name) == -1) + goto abort_free_keynames; register_c0(tk, TERMKEY_SYM_BACKSPACE, 0x08, NULL); register_c0(tk, TERMKEY_SYM_TAB, 0x09, NULL); @@ -1017,7 +1018,9 @@ TermKeySym termkey_register_keyname(TermKey *tk, TermKeySym sym, const char *nam if(sym >= tk->nkeynames) { const char **new_keynames = realloc(tk->keynames, sizeof(new_keynames[0]) * (sym + 1)); - // TODO: Handle realloc() failure + if(!new_keynames) + return -1; + tk->keynames = new_keynames; // Fill in the hole |