mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
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
1 changed files with 3 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue