Skip to content

Commit

Permalink
[posix] fixed uninitialized pointer read (openthread#9552)
Browse files Browse the repository at this point in the history
This commit added validation for whether the pointer (reqs) being
freed is nullptr or not.
  • Loading branch information
hastigondaliya committed Oct 25, 2023
1 parent 9106817 commit 0370c5e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/posix/platform/infra_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,9 @@ void InfraNetif::DiscoverNat64PrefixDone(union sigval sv)

otError InfraNetif::DiscoverNat64Prefix(uint32_t aInfraIfIndex)
{
otError error = OT_ERROR_NONE;
struct addrinfo *hints = nullptr;
struct gaicb *reqs[1];
otError error = OT_ERROR_NONE;
struct addrinfo *hints = nullptr;
struct gaicb *reqs[1] = {nullptr};
struct sigevent sig;
int status;

Expand Down Expand Up @@ -710,7 +710,10 @@ otError InfraNetif::DiscoverNat64Prefix(uint32_t aInfraIfIndex)
{
freeaddrinfo(hints);
}
free(reqs[0]);
if (reqs[0])
{
free(reqs[0]);
}
}
return error;
}
Expand Down

0 comments on commit 0370c5e

Please sign in to comment.