<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - False positive warning "Use of memory after it is freed""
href="https://bugs.llvm.org/show_bug.cgi?id=44203">44203</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive warning "Use of memory after it is freed"
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ynezz@true.cz
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>