diff options
author | erw7 <erw7.github@gmail.com> | 2020-08-01 01:52:15 +0900 |
---|---|---|
committer | erw7 <erw7.github@gmail.com> | 2020-08-02 22:33:18 +0900 |
commit | 872ecf65d10f0d22bbf3e2257f9ae89a6c61d2f4 (patch) | |
tree | bf1c44a2bd8c44be2114e00b8411971cb5ab6306 /src/nvim/highlight.c | |
parent | 1153ac9036ab62ee25078248a01dc56a2311b9a6 (diff) | |
download | rneovim-872ecf65d10f0d22bbf3e2257f9ae89a6c61d2f4.tar.gz rneovim-872ecf65d10f0d22bbf3e2257f9ae89a6c61d2f4.tar.bz2 rneovim-872ecf65d10f0d22bbf3e2257f9ae89a6c61d2f4.zip |
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
Diffstat (limited to 'src/nvim/highlight.c')
-rw-r--r-- | src/nvim/highlight.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index c0cae54572..262afba07a 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -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); |