bpo-40489: Add test case for dict contain use after free (GH-19906)

This commit is contained in:
Dong-hee Na 2020-05-05 02:30:42 +09:00 committed by GitHub
parent caa3ef284a
commit 785f5e6d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -1324,6 +1324,19 @@ class DictTest(unittest.TestCase):
d = {0: set()}
(0, X()) in d.items()
def test_dict_contain_use_after_free(self):
# bpo-40489
class S(str):
def __eq__(self, other):
d.clear()
return NotImplemented
def __hash__(self):
return hash('test')
d = {S(): 'value'}
self.assertFalse('test' in d)
def test_init_use_after_free(self):
class X:
def __hash__(self):