Limit the index to the fixed gas mixes

The index in the gas change event should refer to the one of the fixed
gas mixes. All gas mixes with a higher index are either manual or
bailout gas mixes, and are reported with different events containing an
O2 and He percentages instead.
This commit is contained in:
Jef Driesen 2023-02-15 21:07:02 +01:00
parent 98c7887e9c
commit 328812e95b

View File

@ -902,8 +902,8 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT;
}
unsigned int idx = data[offset];
if (idx < 1 || idx > parser->ngasmixes) {
ERROR(abstract->context, "Invalid gas mix.");
if (idx < 1 || idx > parser->nfixed) {
ERROR(abstract->context, "Invalid gas mix (%u).", idx);
return DC_STATUS_DATAFORMAT;
}
idx--; /* Convert to a zero based index. */