diff options
| author | Christian Heimes <christian@cheimes.de> | 2013-07-01 23:42:28 +0200 |
|---|---|---|
| committer | Christian Heimes <christian@cheimes.de> | 2013-07-01 23:42:28 +0200 |
| commit | 06aecf81f52ad47f8bcb5e8d10f4277e10b83033 (patch) | |
| tree | fc619b67c6ca880eb11b1f142a240a8e665fc304 /Python/pystate.c | |
| parent | d71dc179c59f0a6e74087ecea134164f0e184ee8 (diff) | |
| download | cpython-06aecf81f52ad47f8bcb5e8d10f4277e10b83033.tar.gz | |
Issue #18328: Reorder ops in PyThreadState_Delete*() functions. Now the
tstate is first removed from TLS and then deallocated.
CID 1019639 (#1 of 1): Use after free (USE_AFTER_FREE)
use_after_free: Using freed pointer tstate.
Diffstat (limited to 'Python/pystate.c')
| -rw-r--r-- | Python/pystate.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index cfd61d0098..772aa53168 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -388,11 +388,11 @@ PyThreadState_Delete(PyThreadState *tstate) { if (tstate == _Py_atomic_load_relaxed(&_PyThreadState_Current)) Py_FatalError("PyThreadState_Delete: tstate is still current"); - tstate_delete_common(tstate); #ifdef WITH_THREAD if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate) PyThread_delete_key_value(autoTLSkey); #endif /* WITH_THREAD */ + tstate_delete_common(tstate); } @@ -406,9 +406,9 @@ PyThreadState_DeleteCurrent() Py_FatalError( "PyThreadState_DeleteCurrent: no current tstate"); _Py_atomic_store_relaxed(&_PyThreadState_Current, NULL); - tstate_delete_common(tstate); if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate) PyThread_delete_key_value(autoTLSkey); + tstate_delete_common(tstate); PyEval_ReleaseLock(); } #endif /* WITH_THREAD */ |
