diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp index 38e706b119e056..380a6e34c6ab6c 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp @@ -81,6 +81,12 @@ CHIP_ERROR InteractiveStartCommand::RunCommand() } } + if (command != nullptr) + { + free(command); + command = nullptr; + } + SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; } diff --git a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm index 5ece0a85a227f6..7fe2d7d236d933 100644 --- a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm +++ b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm @@ -127,6 +127,11 @@ el_status_t StopFunction() } } + if (command != nullptr) { + free(command); + command = nullptr; + } + SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; }