Skip to content

Commit c59aa74

Browse files
committed
Fix BufferedReader.read1 leaving object in reentrant state on error
BufferedReader.read1() could leave the buffered object in a reentrant (locked) state when an exception was raised while allocating the output buffer. This change ensures the internal buffered lock is always released on error, keeping the object in a consistent state after failures. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 03e6457 commit c59aa74

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Modules/_io/bufferedio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ _io__Buffered_read1_impl(buffered *self, Py_ssize_t n)
10731073

10741074
PyBytesWriter *writer = PyBytesWriter_Create(n);
10751075
if (writer == NULL) {
1076+
LEAVE_BUFFERED(self)
10761077
return NULL;
10771078
}
10781079

0 commit comments

Comments
 (0)