Visitar URL original
Stackless issue #219: fix NULL pointer access in PyStackless_Schedule · akruis/cpython@ce72a3f · GitHub
Skip to content

Commit ce72a3f

Browse files
committed
Stackless issue python#219: fix NULL pointer access in PyStackless_Schedule
A NPE occurred, if PyStackless_Schedule gets called from from "outside" and if no current tasklet exists. (cherry picked from commit 05a17b1)
1 parent 500591b commit ce72a3f

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎Stackless/changelog.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Stackless 2.7.XX?
1010

1111
*Release date: XXXX-XX-XX*
1212

13+
- https://github.com/stackless-dev/stackless/issues/219
14+
Fix a NULL pointer access in PyStackless_Schedule, if this function is called
15+
from from "outside" and if no current tasklet exists.
16+
1317

1418
What's New in Stackless 2.7.16?
1519
===============================

‎Stackless/module/stacklessmodule.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,15 @@ PyStackless_Schedule(PyObject *retval, int remove)
182182
{
183183
STACKLESS_GETARG();
184184
PyThreadState *ts = PyThreadState_GET();
185-
PyTaskletObject *prev = ts->st.current, *next = prev->next;
185+
PyTaskletObject *prev = ts->st.current, *next;
186186
PyObject *tmpval, *ret = NULL;
187187
int switched, fail;
188188

189-
if (ts->st.main == NULL) return PyStackless_Schedule_M(retval, remove);
189+
if (ts->st.main == NULL)
190+
return PyStackless_Schedule_M(retval, remove);
190191

192+
assert(prev);
193+
next = prev->next;
191194
/* make sure we hold a reference to the previous tasklet.
192195
* this will be decrefed after the switch is complete
193196
*/

0 commit comments

Comments
 (0)