[LLVMbugs] [Bug 9797] New: False positive: fourth argument can't be null when getaddrinfo() succeeds
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Apr 25 18:53:07 PDT 2011
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: kremenek at apple.com
ReportedBy: bugs+llvm+org at sebastianhahn.net
CC: llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list