From 5a0840d0eac27aae213213303d9f751f643c4618 Mon Sep 17 00:00:00 2001 From: pietfried Date: Thu, 23 Mar 2023 11:12:34 +0100 Subject: [PATCH] checking optional before accessing value Signed-off-by: pietfried --- modules/EnergyManager/Market.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/EnergyManager/Market.cpp b/modules/EnergyManager/Market.cpp index b53036e60..e32c219b6 100644 --- a/modules/EnergyManager/Market.cpp +++ b/modules/EnergyManager/Market.cpp @@ -160,7 +160,7 @@ ScheduleReq Market::get_max_available_energy(const ScheduleReq& request) { (*r).limits_to_leaves.total_power_W.value() / (*r).conversion_efficiency.value_or(1.); } // do we have a lower watt limit on root side? - if ((*r).limits_to_root.total_power_W.has_value() && + if ((*r).limits_to_root.total_power_W.has_value() && a.limits_to_root.total_power_W.has_value() && a.limits_to_root.total_power_W.value() > (*r).limits_to_root.total_power_W.value()) { a.limits_to_root.total_power_W = (*r).limits_to_root.total_power_W.value(); }