From 4301000da145e5687bdfa54ee50d5d460f56d960 Mon Sep 17 00:00:00 2001 From: Michael Rupp <95718139+mykrupp@users.noreply.github.com> Date: Mon, 7 Feb 2022 12:33:17 -0500 Subject: [PATCH] Fix github issue #14321 - Thread end device (Requestor) crashes if it cannot reach the Provider (#14712) * Fix github issue #14321 * Updates from PR suggestions * Restyled by whitespace * Restyled by clang-format * Add verify or die calls to Discovery_ImplPlatform.cpp Co-authored-by: Restyled.io --- src/lib/dnssd/Discovery_ImplPlatform.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index 4e2174b974223d..3584e8f47a5178 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -83,22 +83,31 @@ static void HandleNodeIdResolve(void * context, DnssdService * result, CHIP_ERRO { proxy->OnNodeIdResolutionFailed(PeerId(), error); proxy->Release(); + return; } + VerifyOrDie(proxy != nullptr); + if (result == nullptr) { proxy->OnNodeIdResolutionFailed(PeerId(), CHIP_ERROR_UNKNOWN_RESOURCE_ID); proxy->Release(); + return; } + VerifyOrDie(proxy != nullptr); + PeerId peerId; error = ExtractIdFromInstanceName(result->mName, &peerId); if (CHIP_NO_ERROR != error) { proxy->OnNodeIdResolutionFailed(PeerId(), error); proxy->Release(); + return; } + VerifyOrDie(proxy != nullptr); + ResolvedNodeData nodeData; Platform::CopyString(nodeData.mHostName, result->mHostName); nodeData.mInterfaceId = result->mInterface;