1

what might the **res be if getaddrinfo return non-zero ?

Is it safe, to call freeaddrinfo, with all possible values might be given by getaddrinfo ?(exp. null)

Is it needed, to call freeaddrinfo, if getaddrinfo return non-zero ?

Or, is there a possibility, that getaddrinfo might allocate memory for result, and did not free it, when there are errors ?

And, will there be differences, among different implementations of libc, and OS kernel ?

  • You should probably show your proposed code to provide more context. Did you initialize `res` to `NULL`? Or is it garbage? If you initialized it, you should be safe to call `freeaddrinfo` even if `getaddrinfo` fails. – jww Oct 03 '17 at 14:29
  • Setting *res to 0 is a good idea, but I wonder is it really needed to call freeaddrinfo if it failed – Yongjian Wang Oct 06 '17 at 19:52

0 Answers0