commit | 58fd10ad1f697bd7541ca6f58a46e235db1378ae | [log] [tgz] |
---|---|---|
author | Vivien Nicolas <vnicolas@apple.com> | Tue Sep 06 15:57:58 2022 +0200 |
committer | GitHub <noreply@github.com> | Tue Sep 06 09:57:58 2022 -0400 |
tree | 5ebd514a9f9dde475939a4438d0ef2dc636eef9b | |
parent | 20256919c48d5a09c9d97e2604d35c64f00992d8 [diff] |
Remove a leak when quit() is used in interactive mode, the buffer hol… (#22371) * Remove a leak when quit() is used in interactive mode, the buffer holding the command not beeing freed * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp index 38e706b..380a6e3 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp
@@ -81,6 +81,12 @@ } } + 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 5ece0a8..7fe2d7d 100644 --- a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm +++ b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm
@@ -127,6 +127,11 @@ } } + if (command != nullptr) { + free(command); + command = nullptr; + } + SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; }