http://llvm.org/bugs/show_bug.cgi?id=9797
Summary: False positive: fourth argument can't be null when
getaddrinfo() succeeds
Product: clang
Version: 2.9
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
When using getaddrinfo (signature: int getaddrinfo(const char *hostname, const
char *servname, const struct addrinfo *hints, struct addrinfo **res) ), res
can't be null if the call succeeds. The following code triggers a "Loop
condition is false. " message during analysis:
if (!getaddrinfo(name, NULL, &hints, &res))
for (res_p = res; res_p; res_p = res_p->ai_next) {
...
}
tho clearly, for at least one iteration, the loop must be executed. This
triggers a dereference of null pointer warning further below, when res -
without being modified since the getaddrinfo call - is dereferenced.
I suspect what's going on here is that the analyzer sees the explicit null
check inside the for condition, and decides that the original value might
already have been null. I can work around this warning by adding an assert, but
I suspect the analyzer could be smarter here.
Thanks for your consideration!
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs