]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 19 May 2026 21:11:28 +0000 (23:11 +0200)
committerGitHub <noreply@github.com>
Tue, 19 May 2026 21:11:28 +0000 (23:11 +0200)
(cherry picked from commit 3d2aa899bad1c0e274640dc0c4323f1744e73435)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Modules/_io/winconsoleio.c

index 008f8bf118870f27da581652224d2475695530cd..a2f2642dfcbd27547ef0987d42b4791398d6d68f 100644 (file)
@@ -669,12 +669,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;