mirror of
https://github.com/espressif/openthread.git
synced 2026-07-10 14:20:29 +00:00
[cli] fix crash when full logs is on (#5408)
It is possible that log is printed before the Interpreter (UART or CONSOLE) object is created when FULL LOGS is enabled. In such case, OT crashes. This commit fixes this bug.
This commit is contained in:
@@ -251,6 +251,8 @@ const struct Command Interpreter::sCommands[] = {
|
||||
{"version", &Interpreter::ProcessVersion},
|
||||
};
|
||||
|
||||
Interpreter *Interpreter::sInterpreter = nullptr;
|
||||
|
||||
Interpreter::Interpreter(Instance *aInstance)
|
||||
: mUserCommands(nullptr)
|
||||
, mUserCommandsLength(0)
|
||||
@@ -4679,8 +4681,12 @@ extern "C" void otCliPlatLogv(otLogLevel aLogLevel, otLogRegion aLogRegion, cons
|
||||
OT_UNUSED_VARIABLE(aLogLevel);
|
||||
OT_UNUSED_VARIABLE(aLogRegion);
|
||||
|
||||
VerifyOrExit(Interpreter::IsInitialized(), OT_NOOP);
|
||||
|
||||
Interpreter::GetInterpreter().OutputFormatV(aFormat, aArgs);
|
||||
Interpreter::GetInterpreter().OutputFormat("\r\n");
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace Cli
|
||||
|
||||
Reference in New Issue
Block a user