From ddeea3ce30a253474569a193cc5c9e36015dc3b5 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 8 Mar 2022 01:24:23 +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 (#15914) --- 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;