diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2013-04-13 14:26:58 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2013-04-13 14:26:58 (GMT) |
commit | 64aafeb4de3b5e85007f2107250e6f1da4df2516 (patch) | |
tree | 39057074fa67114998a802a6e2761e37734ce021 /Lib | |
parent | eff64447512b026416fce4e65730e25633a5f1ac (diff) | |
download | cpython-64aafeb4de3b5e85007f2107250e6f1da4df2516.zip cpython-64aafeb4de3b5e85007f2107250e6f1da4df2516.tar.gz cpython-64aafeb4de3b5e85007f2107250e6f1da4df2516.tar.bz2 |
Issue #16447: Fix potential segfault when setting __name__ on a class.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index b5a10ed..3776389 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -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>__... |