sources: check for negative distance

This is not expected to happen, but make sure the endpoints of each
source are in the right order (i.e. the distance is not negative) to
prevent getting a negative depth in the selection.
This commit is contained in:
Miroslav Lichvar 2020-06-04 09:35:52 +02:00
parent faff931a76
commit ed78cda6ad

View file

@ -828,8 +828,9 @@ SRC_SelectSource(SRC_Instance updated_inst)
si->hi_limit += extra_disp; si->hi_limit += extra_disp;
} }
/* Require the root distance to be below the allowed maximum */ /* Require the root distance to be below the allowed maximum and the
if (si->root_distance > max_distance) { endpoints to be in the right order (i.e. a non-negative distance) */
if (!(si->root_distance <= max_distance && si->lo_limit <= si->hi_limit)) {
mark_source(sources[i], SRC_BAD_DISTANCE); mark_source(sources[i], SRC_BAD_DISTANCE);
continue; continue;
} }