https://bugs.llvm.org/show_bug.cgi?id=44203
Bug ID: 44203
Summary: False positive warning "Use of memory after it is
freed"
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: dcough...@apple.com
Reporter: yn...@true.cz
CC: dcough...@apple.com, llvm-bugs@lists.llvm.org
Steps to reproduce:
git clone git://git.openwrt.org/project/libnl-tiny.git && cd libnl-tiny
git revert 7ce813fcd66
mkdir build && cd build && scan-build-10 cmake .. && scan-build-10 make
-j$(nproc)
Copy pasting commit message from commit 7ce813fcd66 which fixes/silence this
warning:
scan-build from clang version 9 complains about following:
nl.c:507:9: warning: Use of memory after it is freed
while (nlmsg_ok(hdr, n)) {
^~~~~~~~~~~~~~~~
which seems to be impossible codepath as clang analyzer doesn't somehow
account properly nl_syserr2nlerr(errno) return value:
} else {
free(msg.msg_control);
free(*buf);
return -nl_syserr2nlerr(errno);
}
which should be always < 0, but analyzer is still checking for > 0 code
path as well for some reason. So in order to make the analyzer happy,
set the buf pointer to NULL explicitly and add assert to make it clear,
that this codepath should never happen.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs