Commit 884332b4 authored by Christian Heimes's avatar Christian Heimes

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
parent 7a5457b6
...@@ -167,7 +167,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) ...@@ -167,7 +167,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)
/* Check for __future__ generator_stop and conditionally turn /* Check for __future__ generator_stop and conditionally turn
* a leaking StopIteration into RuntimeError (with its cause * a leaking StopIteration into RuntimeError (with its cause
* set appropriately). */ * 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)) (CO_FUTURE_GENERATOR_STOP | CO_COROUTINE | CO_ITERABLE_COROUTINE))
{ {
PyObject *exc, *val, *val2, *tb; PyObject *exc, *val, *val2, *tb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment