diff options
Diffstat (limited to 'www/analyzer/potential_checkers.html')
-rw-r--r-- | www/analyzer/potential_checkers.html | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/www/analyzer/potential_checkers.html b/www/analyzer/potential_checkers.html index a06e9426fb5f..101e3c6fc402 100644 --- a/www/analyzer/potential_checkers.html +++ b/www/analyzer/potential_checkers.html @@ -104,6 +104,32 @@ void test() { </pre></div></div></td> <td class="aligned"></td></tr> +<tr><td><div class="namedescr expandable"><span class="name"> +memory.ZeroAlloc</span><span class="lang"> +(C, C++)</span><div class="descr"> +Allocation of zero bytes. +<br>Note: an enhancement to <span class="name">unix.Malloc</span>. +<br>Note: <span class="name">unix.API</span> perform C-checks for zero +allocation. This should be moved to <span class="name">unix.Malloc</span>. +<p>Source: C++03 3.7.3.1p2; C++11 3.7.4.1p2.</p></div></div></td> +<td><div class="exampleContainer expandable"> +<div class="example"><pre> +#include <stdlib.h> + +void test() { + int *p = malloc(0); // warn + free(p); +} +</pre></div> +<div class="example"><pre> +void test() { + int *p = new int[0]; // warn + delete[] p; +} +</pre></div></div></td> +<td class="aligned"><a href="http://reviews.llvm.org/D6178"> +D6178</a></td></tr> + </table> <!-- ======================= constructors/destructors ====================== --> @@ -461,12 +487,22 @@ unix.Malloc</span>. <p>Source: C++03 3.7.3.1p2; C++11 3.7.4.1p2.</p></div></div></td> <td><div class="exampleContainer expandable"> <div class="example"><pre> -int *p = malloc(0); -*p = 1; // warn +#include <stdlib.h> + +void test() { + int *p = (int *)malloc(0); + *p = 1; // warn + free(p); +} </pre></div> <div class="example"><pre> -int *p = new int{}; -int i = *p; // warn +void f(int); + +void test() { + int *p = new int[0]; + f(*p); // warn + delete[] p; +} </pre></div></div></td> <td class="aligned"></td></tr> |