Skip to content

Commit d96208c

Browse files
committed
Add checks for a nominalPower having a value and get slotIndex check correct
1 parent a71bb17 commit d96208c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/app/clusters/device-energy-management-server/device-energy-management-server.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands:
676676
const Structs::SlotAdjustmentStruct::Type & slotAdjustment = iterator.GetValue();
677677

678678
// Check for an invalid slotIndex
679-
if (slotAdjustment.slotIndex > forecast.Value().slots.size())
679+
if (slotAdjustment.slotIndex >= forecast.Value().slots.size())
680680
{
681681
ChipLogError(Zcl, "DEM: Bad slot index %d", slotAdjustment.slotIndex);
682682
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure);
@@ -696,7 +696,8 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands:
696696
// NominalPower is only relevant if PFR is supported
697697
if (HasFeature(Feature::kPowerForecastReporting))
698698
{
699-
if (!slot.minPowerAdjustment.HasValue() || !slot.maxPowerAdjustment.HasValue() ||
699+
if (!slotAdjustment.nominalPower.HasValue() ||
700+
!slot.minPowerAdjustment.HasValue() || !slot.maxPowerAdjustment.HasValue() ||
700701
slotAdjustment.nominalPower.Value() < slot.minPowerAdjustment.Value() ||
701702
slotAdjustment.nominalPower.Value() > slot.maxPowerAdjustment.Value())
702703
{

0 commit comments

Comments
 (0)