fix: pass a value_id the same size of predicate_capture_ids's elements to avoid big-endian integer narrowing

This solves a bug on big-endian architectures where the value would be later passed by reference as an elements "view" before being inserted. The issue is it is casted as a void pointer, and when writing uint16_t's of size 1, only 2 of the 4 bytes are written. This is okay for little-endian systems, but not big-endian
This commit is contained in:
Amaan Qureshi 2023-07-18 05:27:48 -04:00
parent ba9f847155
commit c16a8c71ce
No known key found for this signature in database
GPG key ID: E67890ADC4227273

View file

@ -1788,7 +1788,8 @@ static bool ts_query__analyze_patterns(TSQuery *self, unsigned *error_offset) {
) {
TSQueryPredicateStep *step = &self->predicate_steps.contents[j];
if (step->type == TSQueryPredicateStepTypeCapture) {
array_insert_sorted_by(&predicate_capture_ids, , step->value_id);
uint16_t value_id = step->value_id;
array_insert_sorted_by(&predicate_capture_ids, , value_id);
}
}