<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57324>57324</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Heap-allocated llvm:SmallVector<T, 0> can leak memory
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alinas
      </td>
    </tr>
</table>

<pre>
    A heap-allocated llvm::SmallVector<T, 0> may leak memory if, when it grows its capacity, it is handed a pointer that is identical to getFirstEl().
When N = 0, getFirstEl() points to memory outside of itself (i.e. immediately after itself). When the vector is heap-allocated, getFirstEl() may end up pointing at unallocated memory that malloc() then allocates and returns. Then, in the destructor, isSmall() returns true, as if there was no heap allocated, so the memory is not freed.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1UsGO2yAQ_Rp8Ga3lgO3EBx_Sza566qWr9jwxY5sWgwV4o_x9gWS13WorWTLwhvfePOZs5bU_wky4PqDWdsBAErR-XZg4xu_7Ek9_0BCsY-LxhfFHqJh4ggWvoAl_w0KLdVdQY4IuMxlQASZnLz4uPAy44qDCNaERUB5mNDJKIKxWmUAOwowZUJJMUANqCBYmCs_K-fCkGT8w3pWsOrHq-DMJfAMmTtFGpPy37EbqE8PdmN2Cj8xgx-SH9AixUpVUgloWkir2q6-AY3JyK0hqkIXCTPCae8_GP2T0qXpKhYyEbb0ZUWaC2Nxm3qO928pNL_n4fjckxbc6DzElcBQ2Z3wJLxHLCd48SfLBbflN0qHPj3Snud-BWEAJxRjsmG45gkvcGJsbgQ-NeJt5394yVQUYHZG8515Qv2vbHe_qpmoL2QvZiQ6LoIKm_uunw_O_yRnQ_D05xeZ0P4ew-jRw_Dl-kwrzdi4Hu8RNZrv9HlZnf0XCuFXeb-TjotkLXhdz3zSiQsF3-47XI9Xd2GLb7Dsh9m2FBzkUGs-kfc-aL4xzQxfIFHHNmlOhel5xXh244Lze1W15aLBp8dzIDquxQsnqihZUukw-SuumwvXZ0nmbfAS18sG_g-i9mgxRlov8uIXZuh61MuiLrNxn538AdeQndg">