From a78f18390d7ed67d634df978f1b56ded28c3e20b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 9 Sep 2026 09:28:40 +0200 Subject: [PATCH] Note which inflate session fields are borrowed --- esphome/components/esphome/ota/ota_esphome.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/components/esphome/ota/ota_esphome.h b/esphome/components/esphome/ota/ota_esphome.h index 45def96f02..5b01281045 100644 --- a/esphome/components/esphome/ota/ota_esphome.h +++ b/esphome/components/esphome/ota/ota_esphome.h @@ -215,9 +215,12 @@ class ESPHomeOTAComponent final : public ota::OTAComponent { // Heap-allocated only while a deflate upload is negotiated; the decoder // state is the base so the read callback can recover the session struct InflateSession : OtaInflateState { + // The session outlives the upload it serves, but these three are borrowed + // from inflate_data_'s caller and dangle once that call returns; only that + // call, and the flush and read callback it drives, may read them ESPHomeOTAComponent *self; DataTransfer *xfer; - uint8_t *in; // caller's buffer for the compressed input, valid during inflate_data_ + uint8_t *in; // caller's buffer for the compressed input size_t image_size; size_t written; // inflated bytes in flash size_t flushed; // bytes of the current window already in flash