Merge pull request #12701 from erw7/fix-sattr-t-overflow

ui: fix problem with sattr_T overflow
This commit is contained in:
erw7
2020-08-03 22:57:13 +09:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -11,7 +11,7 @@
// The characters and attributes drawn on grids. // The characters and attributes drawn on grids.
typedef char_u schar_T[(MAX_MCO+1) * 4 + 1]; typedef char_u schar_T[(MAX_MCO+1) * 4 + 1];
typedef int16_t sattr_T; typedef int sattr_T;
/// ScreenGrid represents a resizable rectuangular grid displayed by UI clients. /// ScreenGrid represents a resizable rectuangular grid displayed by UI clients.
/// ///

View File

@@ -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); kv_push(attr_entries, entry);
map_put(HlEntry, int)(attr_entry_ids, entry, id); map_put(HlEntry, int)(attr_entry_ids, entry, id);