From 77428b79c08e03bde518a93de8a24adeb276fd87 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 3 Feb 2026 12:30:05 +0100 Subject: [PATCH] Update esphome/components/api/proto.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- esphome/components/api/proto.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/api/proto.h b/esphome/components/api/proto.h index 1552be5137..552b4a4625 100644 --- a/esphome/components/api/proto.h +++ b/esphome/components/api/proto.h @@ -408,7 +408,11 @@ class DumpBuffer { size_t pos() const { return pos_; } /// Update position after buf_append_printf call void set_pos(size_t pos) { - pos_ = pos; + if (pos >= CAPACITY) { + pos_ = CAPACITY - 1; + } else { + pos_ = pos; + } buf_[pos_] = '\0'; }