mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #16447: Fix potential segfault when setting __name__ on a class.
This commit is contained in:
parent
eff6444751
commit
64aafeb4de
3 changed files with 21 additions and 1 deletions
|
@ -3997,6 +3997,20 @@ order (MRO) for bases """
|
|||
C.__name__ = 'D.E'
|
||||
self.assertEqual((C.__module__, C.__name__), (mod, 'D.E'))
|
||||
|
||||
def test_evil_type_name(self):
|
||||
# A badly placed Py_DECREF in type_set_name led to arbitrary code
|
||||
# execution while the type structure was not in a sane state, and a
|
||||
# possible segmentation fault as a result. See bug #16447.
|
||||
class Nasty(str):
|
||||
def __del__(self):
|
||||
C.__name__ = "other"
|
||||
|
||||
class C:
|
||||
pass
|
||||
|
||||
C.__name__ = Nasty("abc")
|
||||
C.__name__ = "normal"
|
||||
|
||||
def test_subclass_right_op(self):
|
||||
# Testing correct dispatch of subclass overloading __r<op>__...
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue