From e80a9402228907b01230d992f6248e6f590f6fa5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 18 Jan 2026 18:52:49 -1000 Subject: [PATCH] [gdk101] Use stack buffer to eliminate heap allocation for firmware version (#13224) --- esphome/components/gdk101/gdk101.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/components/gdk101/gdk101.cpp b/esphome/components/gdk101/gdk101.cpp index 617e2138fb..ddf38f2f55 100644 --- a/esphome/components/gdk101/gdk101.cpp +++ b/esphome/components/gdk101/gdk101.cpp @@ -163,9 +163,10 @@ bool GDK101Component::read_fw_version_(uint8_t *data) { return false; } - const std::string fw_version_str = str_sprintf("%d.%d", data[0], data[1]); - - this->fw_version_text_sensor_->publish_state(fw_version_str); + // max 8: "255.255" (7 chars) + null + char buf[8]; + snprintf(buf, sizeof(buf), "%d.%d", data[0], data[1]); + this->fw_version_text_sensor_->publish_state(buf); } #endif // USE_TEXT_SENSOR return true;