mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00:00
ui: fix problem with sattr_T overflow
sattr_T was defined as uint16_t. But this is not enough to handle the 24-bit colors of the terminal. To solve this problem, change it to int. In 32bit, int may overflow. So, if it overflows, change it to ignore it without adding more attr_entries. fixes #12366
This commit is contained in:
@@ -90,7 +90,12 @@ static int get_attr_entry(HlEntry entry)
|
||||
}
|
||||
}
|
||||
|
||||
id = (int)kv_size(attr_entries);
|
||||
size_t next_id = kv_size(attr_entries);
|
||||
if (next_id > INT_MAX) {
|
||||
ELOG("The index on attr_entries has overflowed");
|
||||
return 0;
|
||||
}
|
||||
id = (int)next_id;
|
||||
kv_push(attr_entries, entry);
|
||||
|
||||
map_put(HlEntry, int)(attr_entry_ids, entry, id);
|
||||
|
Reference in New Issue
Block a user