From d7cbc17961c4395d8d04bfdd7d734d4e398f0c98 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 24 Aug 2022 22:15:07 -0700 Subject: [PATCH] [posix] initialize `hints` in `InfraNetif::DiscoverNat64Prefix` (#8070) --- src/posix/platform/infra_if.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/posix/platform/infra_if.cpp b/src/posix/platform/infra_if.cpp index 6b4702e68..3fbb4e894 100644 --- a/src/posix/platform/infra_if.cpp +++ b/src/posix/platform/infra_if.cpp @@ -615,7 +615,7 @@ exit: otError InfraNetif::DiscoverNat64Prefix(uint32_t aInfraIfIndex) { otError error = OT_ERROR_NONE; - struct addrinfo *hints; + struct addrinfo *hints = nullptr; struct gaicb * reqs[1]; struct sigevent sig; int status; @@ -649,7 +649,10 @@ otError InfraNetif::DiscoverNat64Prefix(uint32_t aInfraIfIndex) exit: if (error != OT_ERROR_NONE) { - freeaddrinfo(hints); + if (hints) + { + freeaddrinfo(hints); + } free(reqs[0]); } return error;