Skip to content

Commit 7964033

Browse files
committed
chore: resolve comment
1 parent e6c622e commit 7964033

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

Lib/test/test_bytes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,10 +2617,7 @@ def ass_subscript(b, a): # MODIFIES!
26172617

26182618
def ass_subscript2(b, a, c): # MODIFIES!
26192619
b.wait()
2620-
try:
2621-
a[:] = c
2622-
except BufferError:
2623-
return
2620+
a[:] = c
26242621
assert b'\xdd' not in a
26252622

26262623
def mod(b, a):
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
Fix a potential use‑after‑free in :class:`bytearray` search‑like methods by
2-
exporting the instance's buffer to prevent reallocation during the
3-
operation.
1+
Fix a potential use‑after‑free in :class:`bytearray` search‑like methods by exporting the instance's buffer to prevent reallocation during the operation.

Objects/bytearrayobject.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,10 @@ _bytearray_with_buffer(PyByteArrayObject *self, PyObject *sub,
100100
{
101101
PyObject *res;
102102

103-
Py_BEGIN_CRITICAL_SECTION(self);
104103
self->ob_exports++;
105-
Py_END_CRITICAL_SECTION();
106-
107104
res = op(PyByteArray_AS_STRING(self), Py_SIZE(self), sub, start, end);
108-
109-
Py_BEGIN_CRITICAL_SECTION(self);
110105
self->ob_exports--;
111-
assert(self->ob_exports >= 0);
112-
Py_END_CRITICAL_SECTION();
106+
113107
return res;
114108
}
115109

0 commit comments

Comments
 (0)