From 8b110976cadc10cc5d5c650fa1d18bfc5071a694 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 30 Apr 2017 15:55:24 -0400 Subject: [PATCH] better constraint validation --- firmware/controllers/trigger/trigger_structure.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index cd7c999821..fc28b49e67 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -65,8 +65,10 @@ void TriggerShape::calculateTriggerSynchPoint(TriggerState *state DECLARE_ENGINE frontOnlyIndexes[0] = 0; } else { int triggerDefinitionCoordinate = (triggerShapeSynchPointIndex + eventIndex) % engine->engineCycleEventCount; + efiAssertVoid(engine->engineCycleEventCount != 0, "zero engineCycleEventCount"); int triggerDefinitionIndex = triggerDefinitionCoordinate >= size ? triggerDefinitionCoordinate - size : triggerDefinitionCoordinate; float angle = getAngle(triggerDefinitionCoordinate) - firstAngle; + efiAssertVoid(!cisnan(angle), "trgSyncNaN"); fixAngle(angle, "trgSync"); if (engineConfiguration->useOnlyRisingEdgeForTrigger) { if (isFrontEvent[triggerDefinitionIndex]) {