Skip to content

Commit

Permalink
[chip-tool-darwin] AddressSanitizer: heap-use-after-free in printf_co…
Browse files Browse the repository at this point in the history
…mmon (#18202)
  • Loading branch information
vivien-apple authored May 9, 2022
1 parent c880e28 commit b1a0c94
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/chip-tool-darwin/commands/common/CHIPCommandBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ class CHIPCommandBridge : public Command

void SetCommandExitStatus(CHIP_ERROR status)
{
#if CHIP_CONFIG_ERROR_SOURCE
// If there is a filename in the status makes a copy of the filename as the pointer may be released
// when the autorelease pool is drained.
strncpy(mCommandExitStatusFilename, status.GetFile(), sizeof(mCommandExitStatusFilename));
mCommandExitStatusFilename[sizeof(mCommandExitStatusFilename) - 1] = '\0';
mCommandExitStatus = chip::ChipError(status.AsInteger(), mCommandExitStatusFilename, status.GetLine());
#else
mCommandExitStatus = status;
#endif // CHIP_CONFIG_ERROR_SOURCE
ShutdownCommissioner();
StopWaiting();
}
Expand Down Expand Up @@ -71,6 +79,9 @@ class CHIPCommandBridge : public Command
CHIP_ERROR ShutdownCommissioner();
uint16_t CurrentCommissionerIndex();

#if CHIP_CONFIG_ERROR_SOURCE
char mCommandExitStatusFilename[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
#endif // CHIP_CONFIG_ERROR_SOURCE
CHIP_ERROR mCommandExitStatus = CHIP_ERROR_INTERNAL;

CHIP_ERROR StartWaiting(chip::System::Clock::Timeout seconds);
Expand Down

0 comments on commit b1a0c94

Please sign in to comment.