Skip to content

Commit

Permalink
Handle no memory case
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed May 1, 2023
1 parent 6977273 commit 2a09314
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Modules/gcmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,12 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase,
}

PyObject *phase_obj = PyUnicode_FromString(phase);
if (phase_obj == NULL) {
Py_XDECREF(info);
PyErr_WriteUnraisable(NULL);
return;
}

PyObject *stack[] = {phase_obj, info};
for (Py_ssize_t i=0; i<PyList_GET_SIZE(gcstate->callbacks); i++) {
PyObject *r, *cb = PyList_GET_ITEM(gcstate->callbacks, i);
Expand Down

0 comments on commit 2a09314

Please sign in to comment.