From 4a7a8db26c5d644e1c5797d1d81587d71e1febdd Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 7 Mar 2022 16:17:15 +0100 Subject: [PATCH] [chip-tool] Cancel the CHIPCallbacks when the chip-tool ends up to avoid a use-after-free if there is a timeout trying to get the device --- examples/chip-tool/commands/clusters/ModelCommand.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index 9ce82a3592a51a..25ff96ab870e91 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -49,6 +49,12 @@ class ModelCommand : public CHIPCommand return CHIP_ERROR_BAD_REQUEST; }; + void Shutdown() override + { + mOnDeviceConnectedCallback.Cancel(); + mOnDeviceConnectionFailureCallback.Cancel(); + } + private: chip::NodeId mNodeId; std::vector mEndPointId;