diff --git a/src/core/net/ip6.cpp b/src/core/net/ip6.cpp index 0ef583c43..db206c612 100644 --- a/src/core/net/ip6.cpp +++ b/src/core/net/ip6.cpp @@ -1267,15 +1267,15 @@ exit: Error Ip6::HandleDatagram(OwnedPtr aMessagePtr, bool aIsReassembled, uint8_t aRecursionDepth) { - Error error; - Header header; - - VerifyOrExit(aRecursionDepth <= kMaxRecursionDepth, error = kErrorDrop); + Error error; + Header header; bool receive; bool forwardThread; bool forwardHost; uint8_t nextHeader; + VerifyOrExit(aRecursionDepth <= kMaxRecursionDepth, error = kErrorDrop); + SuccessOrExit(error = header.ParseFrom(*aMessagePtr)); if (!aMessagePtr->IsOriginHostTrusted())