diff options
author | Alexey Borzenkov <snaury@gmail.com> | 2014-09-20 23:59:37 +0400 |
---|---|---|
committer | Alexey Borzenkov <snaury@gmail.com> | 2014-09-20 23:59:37 +0400 |
commit | 81cec6d687f30c1ff7d020c227952de2f49848ce (patch) | |
tree | c242e07484499770f43b603adb2a29cd5346ac93 | |
parent | d23996a140defe3bf367d4f9179369980cc68843 (diff) | |
download | greenlet-81cec6d687f30c1ff7d020c227952de2f49848ce.tar.gz |
Use STATE_OK in green_new in case tp_new causes gc
Since gc might cause a thread switch which might use
greenlets, which would leave incorrect ts_current,
and then incorrect default parent for the allocated
greenlet.
-rw-r--r-- | greenlet.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -829,6 +829,10 @@ static PyObject* green_new(PyTypeObject *type, PyObject *args, PyObject *kwds) o = PyBaseObject_Type.tp_new(type, ts_empty_tuple, ts_empty_dict); if (o != NULL) { + if (!STATE_OK) { + Py_DECREF(o); + return NULL; + } Py_INCREF(ts_current); ((PyGreenlet*) o)->parent = ts_current; } |