]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.15] gh-150406: Check result of PyThread_allocate_lock() for netdb_lock (GH-150407...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 30 May 2026 17:15:02 +0000 (19:15 +0200)
committerGitHub <noreply@github.com>
Sat, 30 May 2026 17:15:02 +0000 (17:15 +0000)
(cherry picked from commit 1e18c45495185cb547d43c3dd4c1cbdd8482867b)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
Misc/NEWS.d/next/Library/2026-05-25-17-00-00.gh-issue-150406.jF3g63.rst [new file with mode: 0644]
Modules/socketmodule.c

diff --git a/Misc/NEWS.d/next/Library/2026-05-25-17-00-00.gh-issue-150406.jF3g63.rst b/Misc/NEWS.d/next/Library/2026-05-25-17-00-00.gh-issue-150406.jF3g63.rst
new file mode 100644 (file)
index 0000000..230e961
--- /dev/null
@@ -0,0 +1,3 @@
+Fix a possible crash occurring during :mod:`socket` module initialization
+when the system is out of memory on platforms without a reentrant
+``gethostbyname``.
index 722287fbb134c34815558a3c8a9f8653c2ff698f..cf7aadfe95a721f7bd3f6ef060e666c627b81ef4 100644 (file)
@@ -9285,6 +9285,9 @@ socket_exec(PyObject *m)
     /* Initialize gethostbyname lock */
 #if defined(USE_GETHOSTBYNAME_LOCK)
     netdb_lock = PyThread_allocate_lock();
+    if (netdb_lock == NULL) {
+        goto error;
+    }
 #endif
 
 #ifdef MS_WINDOWS