Skip to content

weakrefobject.c doesn't handle allocate_weakref failures #121652

Closed
@colesbury

Description

@colesbury

Bug report

We need to handle the case where allocate_weakref returns NULL due to an out-of-memory error.

PyWeakReference *newref = allocate_weakref(type, obj, callback);
insert_weakref(newref, list);
UNLOCK_WEAKREFS(obj);
return newref;
}
else {
// We may not be able to safely allocate inside the lock
PyWeakReference *newref = allocate_weakref(type, obj, callback);
LOCK_WEAKREFS(obj);
insert_weakref(newref, list);
UNLOCK_WEAKREFS(obj);
return newref;

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixesinterpreter-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