From bf87f48ffa973a46128ec6d06954a81ba6d5d90c Mon Sep 17 00:00:00 2001 From: James Mulcahy Date: Sun, 13 Sep 2026 20:46:51 -0700 Subject: [PATCH] UpdateManager: abort HTTPS OTA handle on failure When esp_https_ota_get_img_desc or esp_https_ota_perform failed the handle was never released, leaking the HTTP client, socket and OTA buffer on every failed firmware update. Call esp_https_ota_abort on those paths (esp_https_ota_finish already frees the handle itself). Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01X7aYyRjzk53Sd7gxF46E3u --- firmware_espidf/lib/UpdateManager/UpdateManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware_espidf/lib/UpdateManager/UpdateManager.cpp b/firmware_espidf/lib/UpdateManager/UpdateManager.cpp index 2380440..d4cbea4 100644 --- a/firmware_espidf/lib/UpdateManager/UpdateManager.cpp +++ b/firmware_espidf/lib/UpdateManager/UpdateManager.cpp @@ -609,6 +609,7 @@ esp_err_t UpdateManager::_update_firmware_ota() { ret = esp_https_ota_get_img_desc(https_ota_handle, &app_desc); if (ret != ESP_OK) { ESP_LOGE("UpdateManager", "esp_https_ota_get_img_desc failed"); + esp_https_ota_abort(https_ota_handle); return ESP_ERR_NOT_FINISHED; } @@ -657,6 +658,8 @@ esp_err_t UpdateManager::_update_firmware_ota() { return ESP_ERR_NOT_FINISHED; } } else { + // esp_https_ota_finish frees the handle on its own; on this path it must be released explicitly. + esp_https_ota_abort(https_ota_handle); esp_event_post(UPDATEMANAGER_EVENT, updatemanager_event_t::FIRMWARE_UPDATE_FINISHED, NULL, 0, pdMS_TO_TICKS(500)); ESP_LOGI("UpdateManager", "Firmware OTA update failed: %s", esp_err_to_name(ret)); return ESP_ERR_NOT_FINISHED;