Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 785f5e6

Browse filesBrowse files
authored
bpo-40489: Add test case for dict contain use after free (GH-19906)
1 parent caa3ef2 commit 785f5e6
Copy full SHA for 785f5e6

File tree

Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-0
lines changed

‎Lib/test/test_dict.py

Copy file name to clipboardExpand all lines: Lib/test/test_dict.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,19 @@ def __eq__(self, other):
13241324
d = {0: set()}
13251325
(0, X()) in d.items()
13261326

1327+
def test_dict_contain_use_after_free(self):
1328+
# bpo-40489
1329+
class S(str):
1330+
def __eq__(self, other):
1331+
d.clear()
1332+
return NotImplemented
1333+
1334+
def __hash__(self):
1335+
return hash('test')
1336+
1337+
d = {S(): 'value'}
1338+
self.assertFalse('test' in d)
1339+
13271340
def test_init_use_after_free(self):
13281341
class X:
13291342
def __hash__(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.