<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 - Add a checker to detected bad checks of mmap() return value"
href="https://bugs.llvm.org/show_bug.cgi?id=46346">46346</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Add a checker to detected bad checks of mmap() return value
</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>OpenBSD
</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>estetus@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The mmap() POSIX function returns MAP_FAILED or -1 when an error occurs. A
common mistake is to check the return value for 0 instead.
<a href="https://pubs.opengroup.org/onlinepubs/009695399/functions/mmap.html">https://pubs.opengroup.org/onlinepubs/009695399/functions/mmap.html</a>
Example:
```
buflen = statbuf.st_size;
buf = mmap(NULL, buflen, PROT_READ, MAP_PRIVATE|MAP_POPULATE, fd, 0);
- if (!buf)
+ if (buf == MAP_FAILED)
goto err;
*data = buf;
```</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>