[Python-checkins] bpo-40489: Add test case for dict contain use after free (GH-19906)
Dong-hee Na
webhook-mailer at python.org
Mon May 4 13:30:50 EDT 2020
https://github.com/python/cpython/commit/785f5e6d674306052bf865677d885c30561985ae
commit: 785f5e6d674306052bf865677d885c30561985ae
branch: master
author: Dong-hee Na <donghee.na92 at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-05-05T02:30:42+09:00
summary:
bpo-40489: Add test case for dict contain use after free (GH-19906)
files:
M Lib/test/test_dict.py
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index d5a3d9e894574..6b8596fff6a9f 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1324,6 +1324,19 @@ def __eq__(self, other):
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):
More information about the Python-checkins
mailing list