mirror of https://github.com/python/cpython
gh-118272: set stacktop to 0 before freeing contents, to avoid access to invalid objects during GC (#118478)
This commit is contained in:
parent
1161ab9085
commit
6763bfcc0f
|
@ -98,10 +98,11 @@ void
|
|||
_PyFrame_ClearLocals(_PyInterpreterFrame *frame)
|
||||
{
|
||||
assert(frame->stacktop >= 0);
|
||||
for (int i = 0; i < frame->stacktop; i++) {
|
||||
int stacktop = frame->stacktop;
|
||||
frame->stacktop = 0;
|
||||
for (int i = 0; i < stacktop; i++) {
|
||||
Py_XDECREF(frame->localsplus[i]);
|
||||
}
|
||||
frame->stacktop = 0;
|
||||
Py_CLEAR(frame->f_locals);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue