Skip to content

Commit e209539

Browse files
committed
address review
1 parent f789470 commit e209539

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Lib/test/test_bytes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,18 +1382,17 @@ def test_bytearray_api(self):
13821382
except OSError:
13831383
pass
13841384

1385-
def test_mod_use_after_free(self):
1386-
# Prevent UAF in bytearray % (a1, a2) with re-entrant a[12].__repr__.
1385+
def test_mod_concurrent_mutation(self):
1386+
# Prevent crash in __mod__ when formatting mutates the bytearray.
13871387
# Regression test for https://github.com/python/cpython/issues/142557.
1388-
fmt = bytearray(b"%a %a")
1388+
fmt = bytearray(b"%a end")
13891389

13901390
class S:
13911391
def __repr__(self):
13921392
fmt.clear()
13931393
return "E"
13941394

1395-
args = (S(), S())
1396-
self.assertRaises(BufferError, fmt.__mod__, args)
1395+
self.assertRaises(BufferError, fmt.__mod__, S())
13971396

13981397
def test_reverse(self):
13991398
b = bytearray(b'hello')
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Fix a use-after-free crash in :ref:`bytearray.__mod__ <bytes-formatting>` when the
2-
:meth:`~object.__repr__` method of one of the arguments to format mutates
3-
the :class:`bytearray`. Patch by Bénédikt Tran.
1+
Fix a use-after-free crash in :ref:`bytearray.__mod__ <bytes-formatting>` when
2+
the :class:`!bytearray` is mutated while formatting the `%`-style arguments.
3+
Patch by Bénédikt Tran.

0 commit comments

Comments
 (0)