]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984)
authorAN Long <aisk@users.noreply.github.com>
Tue, 19 May 2026 20:31:00 +0000 (05:31 +0900)
committerGitHub <noreply@github.com>
Tue, 19 May 2026 20:31:00 +0000 (22:31 +0200)
Modules/_io/winconsoleio.c

index 677d7e85d4e626fe02136c4774f61ba8914992a6..4a3fc586fa3a1473be773ce2c31a59a3b674b9b5 100644 (file)
@@ -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;