Skip to content

Commit d0ba9c9

Browse files
committed
Address code review
1 parent 4dbb0a7 commit d0ba9c9

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

Objects/genobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ gen_set_name(PyObject *self, PyObject *value, void *Py_UNUSED(ignored))
721721
return -1;
722722
}
723723
Py_BEGIN_CRITICAL_SECTION(self);
724+
// To prevent use-after-free from other threads that reference the gi_name.
724725
_PyObject_XSetRefDelayed(&op->gi_name, Py_NewRef(value));
725726
Py_END_CRITICAL_SECTION();
726727
return 0;
@@ -746,6 +747,7 @@ gen_set_qualname(PyObject *self, PyObject *value, void *Py_UNUSED(ignored))
746747
return -1;
747748
}
748749
Py_BEGIN_CRITICAL_SECTION(self);
750+
// To prevent use-after-free from other threads that reference the gi_qualname.
749751
_PyObject_XSetRefDelayed(&op->gi_qualname, Py_NewRef(value));
750752
Py_END_CRITICAL_SECTION();
751753
return 0;

Objects/typeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3967,6 +3967,7 @@ _PyObject_SetDict(PyObject *obj, PyObject *value)
39673967
return -1;
39683968
}
39693969
Py_BEGIN_CRITICAL_SECTION(obj);
3970+
// To prevent use-after-free from other threads that reference the __dict__
39703971
_PyObject_XSetRefDelayed(dictptr, Py_NewRef(value));
39713972
Py_END_CRITICAL_SECTION();
39723973
return 0;

0 commit comments

Comments
 (0)