[meshcop] fix premature free of finalize message (#4487)

This commit fixes a bug that the finalize message will be prematurely
freed if the joiner is started at the second time without waiting for
the finish of the first initiation.
This commit is contained in:
kangping
2020-01-22 10:05:22 -08:00
committed by Jonathan Hui
parent f0c063f8e9
commit 51bb4be6c4
+8 -6
View File
@@ -163,11 +163,11 @@ void Joiner::Finish(otError aError)
case OT_JOINER_STATE_DISCOVER:
Get<Coap::CoapSecure>().Stop();
FreeJoinerFinalizeMessage();
break;
}
SetState(OT_JOINER_STATE_IDLE);
FreeJoinerFinalizeMessage();
if (mCallback)
{
@@ -450,11 +450,13 @@ exit:
void Joiner::FreeJoinerFinalizeMessage(void)
{
if (mFinalizeMessage != NULL)
{
mFinalizeMessage->Free();
mFinalizeMessage = NULL;
}
VerifyOrExit(mState == OT_JOINER_STATE_IDLE && mFinalizeMessage != NULL);
mFinalizeMessage->Free();
mFinalizeMessage = NULL;
exit:
return;
}
void Joiner::SendJoinerFinalize(void)