[Python-checkins] cpython: Add NULL check for gen->gi_code in gen_send_ex()
christian.heimes
python-checkins at python.org
Thu Sep 8 18:21:31 EDT 2016
https://hg.python.org/cpython/rev/9336b31aa6b3
changeset: 103370:9336b31aa6b3
user: Christian Heimes <christian at python.org>
date: Fri Sep 09 00:20:13 2016 +0200
summary:
Add NULL check for gen->gi_code in gen_send_ex()
_PyGen_Finalize() checks that gen->gi_code is not NULL before it
accesses the flags of the code object. This means that the flag
could be NULL.
It passes down the generatore to gen_close() and gen_send_ex().
gen_send_ex() did not check for gen->gi_code != NULL.
CID 1297900
files:
Objects/genobject.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Objects/genobject.c b/Objects/genobject.c
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -167,7 +167,7 @@
/* Check for __future__ generator_stop and conditionally turn
* a leaking StopIteration into RuntimeError (with its cause
* set appropriately). */
- if (((PyCodeObject *)gen->gi_code)->co_flags &
+ if (gen->gi_code != NULL && ((PyCodeObject *)gen->gi_code)->co_flags &
(CO_FUTURE_GENERATOR_STOP | CO_COROUTINE | CO_ITERABLE_COROUTINE))
{
PyObject *exc, *val, *val2, *tb;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list