Skip to content

cppdap: Donot freeaddrinfo(nullptr)

Đoàn Trần Công Danh requested to merge sgn/cmake:backport-cppdap-118 into master

freeaddrinfo(3) only defined to free one or more addrinfo structures returned by getaddrinfo(3). Thus, it's undefined behaviour for calling freeaddrinfo(3) on nullptr, some libc only call free(3) on the the passed addrinfo, but other libc assumes the addrinfo is always valid.

Let's be explicit instead of relying on undefined behaviours.

Let's drop first call to freeaddrinfo(3) because the addrinfo there is always nullptr and guard the second.

Backport-from: https://github.com/google/cppdap/pull/118

Edited by Đoàn Trần Công Danh

Merge request reports