mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(highlight): fix the seg fault caused by the invalid linked hl ids
This commit is contained in:

committed by
Lewis Russell

parent
9d74dc3ac5
commit
6bcefad5a6
@@ -774,7 +774,8 @@ int object_to_hl_id(Object obj, const char *what, Error *err)
|
|||||||
String str = obj.data.string;
|
String str = obj.data.string;
|
||||||
return str.size ? syn_check_group(str.data, str.size) : 0;
|
return str.size ? syn_check_group(str.data, str.size) : 0;
|
||||||
} else if (obj.type == kObjectTypeInteger) {
|
} else if (obj.type == kObjectTypeInteger) {
|
||||||
return MAX((int)obj.data.integer, 0);
|
int id = (int)obj.data.integer;
|
||||||
|
return (1 <= id && id <= highlight_num_groups()) ? id : 0;
|
||||||
} else {
|
} else {
|
||||||
api_set_error(err, kErrorTypeValidation, "Invalid highlight: %s", what);
|
api_set_error(err, kErrorTypeValidation, "Invalid highlight: %s", what);
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -1648,6 +1648,7 @@ static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
|
|||||||
PUT_C(*hl, "default", BOOLEAN_OBJ(true));
|
PUT_C(*hl, "default", BOOLEAN_OBJ(true));
|
||||||
}
|
}
|
||||||
if (link > 0) {
|
if (link > 0) {
|
||||||
|
assert(1 <= link && link <= highlight_ga.ga_len);
|
||||||
PUT_C(*hl, "link", CSTR_AS_OBJ(hl_table[link - 1].sg_name));
|
PUT_C(*hl, "link", CSTR_AS_OBJ(hl_table[link - 1].sg_name));
|
||||||
}
|
}
|
||||||
Dictionary hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
|
Dictionary hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||||
|
Reference in New Issue
Block a user