Skip to content

Commit

Permalink
Fix reference leak with coroutine send().
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroIntensity committed Aug 3, 2024
1 parent 5ac6fc6 commit 3466ac3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/_pyawaitable/coro.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ awaitable_send_with_arg(PyObject *self, PyObject *value)
if (gen == NULL)
return NULL;

Py_DECREF(gen);
Py_RETURN_NONE;
}

Expand Down Expand Up @@ -101,10 +102,11 @@ awaitable_am_send(PyObject *self, PyObject *arg, PyObject **presult)
PyObject *send_res = awaitable_send_with_arg(self, arg);
if (send_res == NULL)
{
PyObject *occurred = PyErr_Occurred();
if (PyErr_GivenExceptionMatches(occurred, PyExc_StopIteration))
if (PyErr_ExceptionMatches(PyExc_StopIteration))
{
PyObject *occurred = PyErr_GetRaisedException();
PyObject *item = PyObject_GetAttrString(occurred, "value");
Py_DECREF(occurred);

if (item == NULL)
{
Expand Down

0 comments on commit 3466ac3

Please sign in to comment.