From acef5ad5bbb8c2b96126ef5ecba0d12efd15d833 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 27 Mar 2026 15:59:01 -1000 Subject: [PATCH] Fix off-by-one in debug assert: size + 1 must also fit in uint16_t --- esphome/core/helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 5940f6ec98..4768c4eb95 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -24,7 +24,7 @@ static const char *const TAG = "helpers"; __attribute__((noinline, cold)) void *callback_manager_grow(void *data, uint16_t size, uint16_t &capacity, size_t elem_size) { - ESPHOME_DEBUG_ASSERT(size < UINT16_MAX); + ESPHOME_DEBUG_ASSERT(size < UINT16_MAX - 1); uint16_t new_cap = size + 1; auto *new_data = ::operator new(new_cap *elem_size); if (data) {