From 5d9371340425e9d264af797779a9a83915c7f9ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 30 Mar 2026 22:15:34 -1000 Subject: [PATCH] [time] Guard against format string ending with bare % --- esphome/core/time.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/time.cpp b/esphome/core/time.cpp index 46e38fb3b64..b6fc9b90ad9 100644 --- a/esphome/core/time.cpp +++ b/esphome/core/time.cpp @@ -24,7 +24,7 @@ size_t ESPTime::strftime(char *buffer, size_t buffer_len, const char *format) { // Quick scan: does format contain %Z or %z (but not %%Z/%%z)? bool needs_subst = false; for (const char *p = format; *p; p++) { - if (*p == '%') { + if (*p == '%' && *(p + 1)) { p++; if (*p == '%') continue; // %% is a literal %, skip