diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index ca1738bc8b6715..bea828262d3554 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -104,8 +104,11 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal virtual void OnDone(chip::app::CommandSender * client) override { - mCommandSender.front().reset(); - mCommandSender.erase(mCommandSender.begin()); + if (mCommandSender.size()) + { + mCommandSender.front().reset(); + mCommandSender.erase(mCommandSender.begin()); + } // If the command is repeated N times, wait for all the responses to comes in // before exiting.