<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 - Spurious warning "Use of memory after it is freed" after realloc"
href="https://bugs.llvm.org/show_bug.cgi?id=46314">46314</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Spurious warning "Use of memory after it is freed" after realloc
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>dank@kegel.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The code
a (int x)
{
char in, re;
unsigned next;
in = malloc (1);
next = 0;
if (x)
next = 2;
re = realloc (in, next);
return re == ((void *) 0) ? in : re;
}
causes --analyze to emit
bad.c:10:3: warning: Use of memory after it is freed [unix.Malloc]
return re == ((void *) 0) ? in : re;
which appears to be a false positive.
Tested with
Ubuntu clang version
11.0.0-++20200612052611+b2a37cfe2bd-1~exp1~20200612153223.70
but also affects
clang version 11.0.0-++20200523063809+304b0ed4039-1~exp1~20200523164413.1701
Reduced from <a href="https://github.com/zlib-ng/zlib-ng/issues/593">https://github.com/zlib-ng/zlib-ng/issues/593</a></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>