X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Fcomp_hash.c;h=a62d38f9dc8da7c0fff6fdbfeda2a7af2ad9fa49;hp=21f165ca2e42bd0ac65d10f8016cb6cab5b4ab95;hb=119b5a6788c26bf7dcc99fcfd54e072946352a93;hpb=cdaf29481becd3e1c21baa574ac1ab88ea5f3d38 diff --git a/ncurses/tinfo/comp_hash.c b/ncurses/tinfo/comp_hash.c index 21f165ca..a62d38f9 100644 --- a/ncurses/tinfo/comp_hash.c +++ b/ncurses/tinfo/comp_hash.c @@ -44,7 +44,7 @@ #include #include -MODULE_ID("$Id: comp_hash.c,v 1.49 2019/03/10 00:06:48 tom Exp $") +MODULE_ID("$Id: comp_hash.c,v 1.51 2019/10/12 16:32:13 tom Exp $") /* * Finds the entry for the given string in the hash table if present. @@ -63,7 +63,9 @@ _nc_find_entry(const char *string, hashvalue = data->hash_of(string); - if (data->table_data[hashvalue] >= 0) { + if (hashvalue >= 0 + && (unsigned) hashvalue < data->table_size + && data->table_data[hashvalue] >= 0) { real_table = _nc_get_table(termcap); ptr = real_table + data->table_data[hashvalue]; @@ -96,7 +98,9 @@ _nc_find_type_entry(const char *string, const HashData *data = _nc_get_hash_info(termcap); int hashvalue = data->hash_of(string); - if (data->table_data[hashvalue] >= 0) { + if (hashvalue >= 0 + && (unsigned) hashvalue < data->table_size + && data->table_data[hashvalue] >= 0) { const struct name_table_entry *const table = _nc_get_table(termcap); ptr = table + data->table_data[hashvalue]; @@ -124,7 +128,9 @@ _nc_find_user_entry(const char *string) hashvalue = data->hash_of(string); - if (data->table_data[hashvalue] >= 0) { + if (hashvalue >= 0 + && (unsigned) hashvalue < data->table_size + && data->table_data[hashvalue] >= 0) { real_table = _nc_get_userdefs_table(); ptr = real_table + data->table_data[hashvalue];