Skip to content

Possible memory leak on fail path in dictiter_iternextitem #140058

@sergey-miryanov

Description

@sergey-miryanov

Bug report

Bug description:

Following code should decref key and value if PyTuple_New fails:

cpython/Objects/dictobject.c

Lines 5720 to 5726 in 6481539

else {
result = PyTuple_New(2);
if (result == NULL)
return NULL;
PyTuple_SET_ITEM(result, 0, key);
PyTuple_SET_ITEM(result, 1, value);
}

I have PR ready.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

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