mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #16445: Fix potential segmentation fault when deleting an exception message.
This commit is contained in:
parent
ff0deb0529
commit
7cac1c25a1
3 changed files with 16 additions and 2 deletions
|
@ -479,6 +479,18 @@ class ExceptionTests(unittest.TestCase):
|
|||
except AssertionError as e:
|
||||
self.assertEqual(str(e), "(3,)")
|
||||
|
||||
def test_bad_exception_clearing(self):
|
||||
# See issue 16445: use of Py_XDECREF instead of Py_CLEAR in
|
||||
# BaseException_set_message gave a possible way to segfault the
|
||||
# interpreter.
|
||||
class Nasty(str):
|
||||
def __del__(message):
|
||||
del e.message
|
||||
|
||||
e = ValueError(Nasty("msg"))
|
||||
e.args = ()
|
||||
del e.message
|
||||
|
||||
|
||||
# Helper class used by TestSameStrAndUnicodeMsg
|
||||
class ExcWithOverriddenStr(Exception):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue