summaryrefslogtreecommitdiffstats
path: root/Objects/genobject.c
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2012-01-13 20:06:12 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2012-01-13 20:06:12 (GMT)
commite557da804aae6ae6478809243c349659f5c3e722 (patch)
tree8bd67c70fc72c5cf33734d9a9f78c70e9f6ac7a2 /Objects/genobject.c
parent7e447c8224c0ce7748dfd502c746139965d2d1e4 (diff)
downloadcpython-e557da804aae6ae6478809243c349659f5c3e722.zip
cpython-e557da804aae6ae6478809243c349659f5c3e722.tar.gz
cpython-e557da804aae6ae6478809243c349659f5c3e722.tar.bz2
Fix a crash when the return value of a subgenerator is a temporary
object (with a refcount of 1)
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r--Objects/genobject.c3
1 files changed, 2 insertions, 1 deletions
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 @@ PyGen_FetchStopIterationValue(PyObject **pvalue) {
Py_XDECREF(tb);
if (ev) {
value = ((PyStopIterationObject *)ev)->value;
+ Py_INCREF(value);
Py_DECREF(ev);
}
} else if (PyErr_Occurred()) {
@@ -482,8 +483,8 @@ PyGen_FetchStopIterationValue(PyObject **pvalue) {
}
if (value == NULL) {
value = Py_None;
+ Py_INCREF(value);
}
- Py_INCREF(value);
*pvalue = value;
return 0;
}