From 8691e883e3ec40fabd50006d532869f8acb9c401 Mon Sep 17 00:00:00 2001 From: samuelsadok Date: Wed, 26 Jan 2022 11:47:14 +0100 Subject: [PATCH] fix memory leak in libfibre --- Firmware/fibre-cpp/legacy_object_client.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Firmware/fibre-cpp/legacy_object_client.cpp b/Firmware/fibre-cpp/legacy_object_client.cpp index d61ad216d..1113b37d2 100644 --- a/Firmware/fibre-cpp/legacy_object_client.cpp +++ b/Firmware/fibre-cpp/legacy_object_client.cpp @@ -477,13 +477,12 @@ void LegacyCallContext::resume_from_protocol(EndpointOperationResult result) { auto continuation = get_next_task(res); if (continuation.index() == 0) { auto app_result = callback.invoke(std::get<0>(continuation)); - if (!app_result.has_value()) { - return; // app will resume asynchronously - } else if (std::get<0>(continuation).status != kFibreOk) { - if (app_result->status != kFibreClosed || app_result->rx_buf.size() || app_result->tx_buf.size()) { + if (std::get<0>(continuation).status != kFibreOk) { + if (app_result.has_value() && (app_result->status != kFibreClosed || app_result->rx_buf.size() || app_result->tx_buf.size())) { FIBRE_LOG(W) << "app tried to continue a closed call"; } FIBRE_LOG(T) << "closing call"; + delete this; return; } else { res = *app_result;