summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-11 07:28:45 (GMT)
committerGitHub <noreply@github.com>2024-06-11 07:28:45 (GMT)
commit52225c64f7cd55f2bfe8515d4daf1a5ed4be6d7b (patch)
treea2ac89998c6c0baccb97dd71faa0442906fd77cb /Lib/test
parent81eae217335fc66bec343b9f11f1b68fe85667bf (diff)
downloadcpython-52225c64f7cd55f2bfe8515d4daf1a5ed4be6d7b.zip
cpython-52225c64f7cd55f2bfe8515d4daf1a5ed4be6d7b.tar.gz
cpython-52225c64f7cd55f2bfe8515d4daf1a5ed4be6d7b.tar.bz2
[3.13] gh-120298: Fix use-after-free in `list_richcompare_impl` (GH-120303) (#120340)
gh-120298: Fix use-after-free in `list_richcompare_impl` (GH-120303) (cherry picked from commit 141babad9b4eceb83371bf19ba3a36b50dd05250) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_list.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py
index 0601b33..d21429f 100644
--- a/Lib/test/test_list.py
+++ b/Lib/test/test_list.py
@@ -234,6 +234,17 @@ class ListTest(list_tests.CommonTest):
list4 = [1]
self.assertFalse(list3 == list4)
+ def test_lt_operator_modifying_operand(self):
+ # See gh-120298
+ class evil:
+ def __lt__(self, other):
+ other.clear()
+ return NotImplemented
+
+ a = [[evil()]]
+ with self.assertRaises(TypeError):
+ a[0] < a
+
@cpython_only
def test_preallocation(self):
iterable = [0] * 10