On Sat Oct 21 09:26:42 2023 +0000, Jinoh Kang wrote:
The failure mode of allocation seems a bit off. When we fail to `calloc`, we have three choices of behaviors:
- Crash.
- Fail with error.
- Revert to the old behavior of delegating to actual DNS query, which
will mask the alloc failure with some other query error. Here we do (3), which seems to be the most confusing choice here.[^1] Can we just drop the NULL check or handle the error properly? (Ditto for IPv6.) [^1]: Why? If the allocation ever fails, it will unpredictably return bogus NXDOMAIN answer to the application. If it never fails, then there is no reason for the NULL check in the first place.
Will this nit change anything in practice? If a few bytes can't be allocated, it is done already, abstract perfection of such a place doesn't worth any extra line of code. Regarding dropping the null check, I think the common rule in Wine is to check the allocations. I'd personally would agree that in many cases just skipping the check and crashing would make more sense than putting code for any handling the error just anyhow, but I am just following what I think is the rule here.
Doesn't matter, but I think it won't get an unpredicatable result on the main path. It will fail to allocate memory later and get an error, or, in case of miraculous getting memory back, it will get an error anyway being unable to find it (both errors, ERROR_OUT_OF_MEMORY or what it would get, are not the correct result anyway).