From: AN Long Date: Tue, 19 May 2026 20:31:00 +0000 (+0900) Subject: gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d2aa899bad1c0e274640dc0c4323f1744e73435;p=thirdparty%2FPython%2Fcpython.git gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984) --- diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c index 677d7e85d4e6..4a3fc586fa3a 100644 --- a/Modules/_io/winconsoleio.c +++ b/Modules/_io/winconsoleio.c @@ -673,12 +673,13 @@ read_console_w(HANDLE handle, DWORD maxlen, DWORD *readlen) { maxlen += 1; Py_BLOCK_THREADS newbuf = (wchar_t*)PyMem_Realloc(buf, maxlen * sizeof(wchar_t)); - Py_UNBLOCK_THREADS if (!newbuf) { sig = -1; PyErr_NoMemory(); + Py_UNBLOCK_THREADS break; } + Py_UNBLOCK_THREADS buf = newbuf; /* Only advance by n and not BUFSIZ in this case */ off += n;