<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Static analyzer incorrectly reports leaks when realloc fails"
href="http://llvm.org/bugs/show_bug.cgi?id=16730">16730</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Static analyzer incorrectly reports leaks when realloc fails
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Static Analyzer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>kremenek@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>labath@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>klimek@google.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>$ cat leak.c
#include <stdlib.h>
void Realloc(void** memory) {
*memory = malloc(47);
char* new_memory = realloc(*memory, 47);
if (new_memory != NULL) {
*memory = new_memory;
}
}
$ ~/llvm/build/bin/clang --analyze leak.c
leak.c:9:1: warning: Potential memory leak
}
^
1 warning generated.
The problem with the above warning is that even if the realloc fails, the first
allocated block of memory will still be addressable by *memory (which will be
available to the caller). Therefore, this should not be reported as leaked.</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>