From 0f1993f8ea81a5c8ac3c4c1420b58ece937eb979 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 23 Aug 2024 17:16:20 -0400 Subject: [PATCH] Update src/app/clusters/thermostat-server/thermostat-server-presets.cpp --- .../thermostat-server/thermostat-server-presets.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/app/clusters/thermostat-server/thermostat-server-presets.cpp b/src/app/clusters/thermostat-server/thermostat-server-presets.cpp index 8bd7f0f496f766..83d5f710defd66 100644 --- a/src/app/clusters/thermostat-server/thermostat-server-presets.cpp +++ b/src/app/clusters/thermostat-server/thermostat-server-presets.cpp @@ -407,12 +407,8 @@ CHIP_ERROR ThermostatAttrAccess::AppendPendingPreset(Thermostat::Delegate * dele uint8_t numberOfPendingPresets = CountNumberOfPendingPresets(delegate); - // Increment number of pending presets by 1 to account for this preset. - uint8_t totalExpectedCount = numberOfPendingPresets + 1; - - uint8_t numberOfPresetsSupported = delegate->GetNumberOfPresets(); - - if (totalExpectedCount > numberOfPresetsSupported) + // We will be adding one more preset, so reject if the length is already at max. + if (numberOfPendingPresets >= numberOfPresetsSupported) { return CHIP_IM_GLOBAL_STATUS(ResourceExhausted); }