From getifaddrs(3):
The ifa_addr field points to a structure containing the interface
address. (The sa_family subfield should be consulted to
determine the format of the address structure.) This field may
contain a null pointer.
I have the problem with tun0, that creates points-to-point address, so
getifaddrs() returns NULL ifa_addr for one of addrs for tun0.
You can check this, using this simple example - [1].
[1]: https://gist.github.com/azat/cc667d145bc74215c40cdbb69f38189b