@@ -1263,7 +1263,7 @@ slp_eval_frame_setup_with(PyFrameObject *f, int throwflag, PyObject *retval)
1263
1263
* SETUP_WITH operation.
1264
1264
* NOTE / XXX: see above.
1265
1265
*/
1266
- Py_XINCREF (f ); /* fool the link optimizer */
1266
+ Py_XINCREF (f ); /* fool the link optimizer */
1267
1267
Py_XINCREF (retval ); /* fool the link optimizer */
1268
1268
r = slp_eval_frame_value (f , throwflag , retval );
1269
1269
Py_XDECREF (retval );
@@ -1282,7 +1282,7 @@ slp_eval_frame_with_cleanup(PyFrameObject *f, int throwflag, PyObject *retval)
1282
1282
* NOTE / XXX: see above.
1283
1283
*/
1284
1284
Py_XINCREF (f ); /* fool the link optimizer */
1285
- Py_XINCREF (f ); /* fool the link optimizer */
1285
+ Py_XINCREF (f ); /* fool the link optimizer */
1286
1286
r = slp_eval_frame_value (f , throwflag , retval );
1287
1287
Py_XDECREF (f );
1288
1288
Py_XDECREF (f );
@@ -1708,8 +1708,10 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
1708
1708
1709
1709
why = WHY_NOT ;
1710
1710
1711
- if (throwflag ) /* support for generator.throw() */
1711
+ if (throwflag ) { /* support for generator.throw() */
1712
+ assert (retval == NULL ); /* to prevent reference leaks */
1712
1713
goto error ;
1714
+ }
1713
1715
1714
1716
1715
1717
#ifdef STACKLESS
@@ -1733,6 +1735,7 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
1733
1735
}
1734
1736
else if (!PyErr_Occurred ()) {
1735
1737
/* iterator ended normally */
1738
+ assert (retval == NULL ); /* to prevent reference leaks */
1736
1739
retval = POP ();
1737
1740
Py_DECREF (retval );
1738
1741
/* perform the delayed block jump */
@@ -1746,6 +1749,7 @@ slp_eval_frame_value(PyFrameObject *f, int throwflag, PyObject *retval)
1746
1749
if (tstate -> c_tracefunc != NULL )
1747
1750
call_exc_trace (tstate -> c_tracefunc , tstate -> c_traceobj , tstate , f );
1748
1751
PyErr_Clear ();
1752
+ assert (retval == NULL ); /* to prevent reference leaks */
1749
1753
retval = POP ();
1750
1754
Py_DECREF (retval );
1751
1755
JUMPBY (oparg );
0 commit comments