From f5fc06fd9e5323403b51e0a13beaecc1c7fc091f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 2 Oct 2025 23:03:53 +0200 Subject: [PATCH] preen --- esphome/core/helpers.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 2c65bec6e6..33916515d8 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -366,7 +366,9 @@ std::string value_accuracy_to_string(float value, int8_t accuracy_decimals) { std::string value_accuracy_with_uom_to_string(float value, int8_t accuracy_decimals, StringRef unit_of_measurement) { normalize_accuracy_decimals(value, accuracy_decimals); - char tmp[64]; // Increased to accommodate unit of measurement + // Buffer sized for float (up to ~15 chars) + space + typical UOM (usually <20 chars like "μS/cm") + // snprintf truncates safely if exceeded, though ESPHome UOMs are typically short + char tmp[64]; if (unit_of_measurement.empty()) { snprintf(tmp, sizeof(tmp), "%.*f", accuracy_decimals, value); } else {