From 51d0a5c9248a79ba59f404a1d29ac029c41a268c Mon Sep 17 00:00:00 2001 From: Jakub Gonera Date: Tue, 3 Jun 2025 16:32:59 +0200 Subject: [PATCH] fix: remove dangling reference --- .../rnexecutorch/host_objects/ModelHostObject.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/react-native-executorch/common/rnexecutorch/host_objects/ModelHostObject.h b/packages/react-native-executorch/common/rnexecutorch/host_objects/ModelHostObject.h index a81aebcce..bf61a9d23 100644 --- a/packages/react-native-executorch/common/rnexecutorch/host_objects/ModelHostObject.h +++ b/packages/react-native-executorch/common/rnexecutorch/host_objects/ModelHostObject.h @@ -69,16 +69,19 @@ template class ModelHostObject : public JsiHostObject { // breaks proper exception type checking. Remove when the // following change is present in our version: // https://github.com/facebook/react-native/commit/3132cc88dd46f95898a756456bebeeb6c248f20e - callInvoker->invokeAsync( - [&e, promise]() { promise->reject(e.what()); }); + callInvoker->invokeAsync([e = std::move(e), promise]() { + promise->reject(e.what()); + }); return; } catch (const jsi::JSError &e) { - callInvoker->invokeAsync( - [&e, promise]() { promise->reject(e.what()); }); + callInvoker->invokeAsync([e = std::move(e), promise]() { + promise->reject(e.what()); + }); return; } catch (const std::exception &e) { - callInvoker->invokeAsync( - [&e, promise]() { promise->reject(e.what()); }); + callInvoker->invokeAsync([e = std::move(e), promise]() { + promise->reject(e.what()); + }); return; } catch (...) { callInvoker->invokeAsync(