Skip to content

Memory leak in _tuple_shared() on PyMem_Calloc() failure #147960

Description

@hyongtao-code

Bug report

Bug description:

In _tuple_shared() (crossinterp_data_lookup.h), there is a memory leak when allocation of the items array fails. This only affects the OOM/error path.

Specifically:

struct_shared_tuple_data*shared=PyMem_RawMalloc(...);
...
shared->items=PyMem_Calloc(...);
if (shared->items==NULL) {
PyErr_NoMemory();
return-1;
}

Related to #146102

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions