mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 23:57:47 +00:00
[cli] add UDP socket openness check before sending with udp send (#10206)
Problem: Executing the `udp send` command in CLI without previously
opening the example udp socket results in an unhandled null-pointer
exception.
Solution: Before anything is processed in the
`UdpExample::Process<Cmd("send")>(Arg aArgs[])` method, the UDP socket
is checked whether it's open or not. If not, the method returns with
OT_ERROR_INVALID_STATE error avoiding the null-pointer exception.
This commit is contained in:
@@ -256,6 +256,8 @@ template <> otError UdpExample::Process<Cmd("send")>(Arg aArgs[])
|
||||
otMessageInfo messageInfo;
|
||||
otMessageSettings messageSettings = {mLinkSecurityEnabled, OT_MESSAGE_PRIORITY_NORMAL};
|
||||
|
||||
VerifyOrExit(otUdpIsOpen(GetInstancePtr(), &mSocket), error = OT_ERROR_INVALID_STATE);
|
||||
|
||||
ClearAllBytes(messageInfo);
|
||||
|
||||
// Possible argument formats:
|
||||
|
||||
Reference in New Issue
Block a user