From adbd41f2bda3a4a2d0115601b824bb1fa4b75510 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 12 Aug 2020 22:18:56 -0700 Subject: [PATCH] safety --- firmware/controllers/algo/fuel_math.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index c0dde746ef..5f19441c5e 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -265,8 +265,16 @@ float getInjectionModeDurationMultiplier(DECLARE_ENGINE_PARAMETER_SIGNATURE) { injection_mode_e mode = ENGINE(getCurrentInjectionMode(PASS_ENGINE_PARAMETER_SIGNATURE)); switch (mode) { - case IM_SIMULTANEOUS: - return 1.0f / engineConfiguration->specs.cylindersCount; + case IM_SIMULTANEOUS: { + auto cylCount = engineConfiguration->specs.cylindersCount; + + if (cylCount == 0) { + // we can end up here during configuration reset + return 0; + } + + return 1.0f / cylCount; + } case IM_SEQUENTIAL: case IM_SINGLE_POINT: return 1;