<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 "use of memory after it is freed" after overwriting struct pointer"
href="https://bugs.llvm.org/show_bug.cgi?id=39356">39356</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>False positive "use of memory after it is freed" after overwriting struct pointer
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>7.0
</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>dcoughlin@apple.com
</td>
</tr>
<tr>
<th>Reporter</th>
<td>peter@lekensteyn.nl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The following minimal reproducer triggers a false positive:
#include <stdlib.h>
struct array {
int count; // first field must be present to trigger issue
int *nodes;
};
// arr must not be an automatic variable, but a parameter or global.
void array_insert(struct array *arr) {
struct array arr2;
arr2.nodes = calloc(1, sizeof(int));
free(arr->nodes);
*arr = arr2;
arr->nodes[0] = 1; // false-positive.c:14:19: warning: Use of memory after
it is freed
}
arr2.nodes is newly allocated and replaces the 'nodes' member of 'arr', but
somehow this is not recognized.</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>