NcpBase: Ensure the sNcpContext is set. (#1038)

This commit fixes issue where `sNcpContext` was NULL and the callbacks
to `otNcpStreamWrite()` would cause a crash.
This commit is contained in:
Abtin Keshavarzian
2016-12-02 15:58:41 -08:00
committed by Jonathan Hui
parent 917fd1d4cc
commit b11b644418
+2 -2
View File
@@ -462,7 +462,7 @@ NcpBase::NcpBase(otInstance *aInstance):
mInstance(aInstance),
mLastStatus(SPINEL_STATUS_OK),
mSupportedChannelMask(kPhySupportedChannelMask),
mChannelMask(mSupportedChannelMask),
mChannelMask(kPhySupportedChannelMask),
mScanPeriod(200), // ms
mUpdateChangedPropsTask(aInstance->mIp6.mTaskletScheduler, &NcpBase::UpdateChangedProps, this),
mChangedFlags(NCP_PLAT_RESET_REASON),
@@ -488,7 +488,7 @@ NcpBase::NcpBase(otInstance *aInstance):
{
assert(mInstance != NULL);
sNcpContext = NULL;
sNcpContext = this;
otSetStateChangedCallback(mInstance, &NcpBase::HandleNetifStateChanged, this);
otSetReceiveIp6DatagramCallback(mInstance, &NcpBase::HandleDatagramFromStack, this);