Fix a crash when the return value of a subgenerator is a temporary
object (with a refcount of 1)
diff --git a/Objects/genobject.c b/Objects/genobject.c
index 20c926b..b32d9b6 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -475,6 +475,7 @@
Py_XDECREF(tb);
if (ev) {
value = ((PyStopIterationObject *)ev)->value;
+ Py_INCREF(value);
Py_DECREF(ev);
}
} else if (PyErr_Occurred()) {
@@ -482,8 +483,8 @@
}
if (value == NULL) {
value = Py_None;
+ Py_INCREF(value);
}
- Py_INCREF(value);
*pvalue = value;
return 0;
}