mirror of
https://github.com/espressif/openthread.git
synced 2026-09-07 01:30:11 +00:00
Add NULL pointer checks to IsStableUpdated(). (#1412)
This commit is contained in:
@@ -491,38 +491,44 @@ bool Leader::IsStableUpdated(uint16_t aRloc16, uint8_t *aTlvs, uint8_t aTlvsLeng
|
||||
bool rval = false;
|
||||
NetworkDataTlv *cur = reinterpret_cast<NetworkDataTlv *>(aTlvs);
|
||||
NetworkDataTlv *end = reinterpret_cast<NetworkDataTlv *>(aTlvs + aTlvsLength);
|
||||
PrefixTlv *prefix;
|
||||
PrefixTlv *prefixBase;
|
||||
BorderRouterTlv *borderRouter;
|
||||
HasRouteTlv *hasRoute;
|
||||
ContextTlv *context;
|
||||
|
||||
while (cur < end)
|
||||
{
|
||||
if (cur->GetType() == NetworkDataTlv::kTypePrefix)
|
||||
{
|
||||
prefix = static_cast<PrefixTlv *>(cur);
|
||||
context = FindContext(*prefix);
|
||||
borderRouter = FindBorderRouter(*prefix);
|
||||
hasRoute = FindHasRoute(*prefix);
|
||||
PrefixTlv *prefix = static_cast<PrefixTlv *>(cur);
|
||||
ContextTlv *context = FindContext(*prefix);
|
||||
BorderRouterTlv *borderRouter = FindBorderRouter(*prefix);
|
||||
HasRouteTlv *hasRoute = FindHasRoute(*prefix);
|
||||
|
||||
if (cur->IsStable() && (!context || borderRouter))
|
||||
{
|
||||
prefixBase = FindPrefix(prefix->GetPrefix(), prefix->GetPrefixLength(), aTlvsBase, aTlvsBaseLength);
|
||||
PrefixTlv *prefixBase = FindPrefix(prefix->GetPrefix(), prefix->GetPrefixLength(),
|
||||
aTlvsBase, aTlvsBaseLength);
|
||||
|
||||
if (!prefixBase)
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
}
|
||||
|
||||
if (borderRouter && memcmp(borderRouter, FindBorderRouter(*prefixBase), borderRouter->GetLength()) != 0)
|
||||
if (borderRouter)
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
BorderRouterTlv *borderRouterBase = FindBorderRouter(*prefixBase);
|
||||
|
||||
if (!borderRouterBase || memcmp(borderRouter, borderRouterBase, borderRouter->GetLength()) != 0)
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasRoute && (memcmp(hasRoute, FindHasRoute(*prefixBase), hasRoute->GetLength()) != 0))
|
||||
if (hasRoute)
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
HasRouteTlv *hasRouteBase = FindHasRoute(*prefixBase);
|
||||
|
||||
if (!hasRouteBase || (memcmp(hasRoute, hasRouteBase, hasRoute->GetLength()) != 0))
|
||||
{
|
||||
ExitNow(rval = true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user