Skip to content

Heap-allocated llvm:SmallVector<T, 0> can leak memory #57324

@alinas

Description

@alinas

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions