]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-151126: Fix a possible crash during the startup with no memory under `Py_ST...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 30 Jun 2026 11:55:16 +0000 (13:55 +0200)
committerGitHub <noreply@github.com>
Tue, 30 Jun 2026 11:55:16 +0000 (11:55 +0000)
gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (GH-152478)
(cherry picked from commit ecdef1773006529b0fea6639d0effeecbb41679c)

Co-authored-by: sobolevn <mail@sobolevn.me>
Python/pystate.c

index 06672ceb2143c902fc13e9d448c03f5566ecdd7e..d1505be4acf50f22cc54bdd91262aff6d1c46028 100644 (file)
@@ -694,6 +694,9 @@ init_interpreter(PyInterpreterState *interp,
         NULL,
         &alloc
     );
+    if (interp->open_stackrefs_table == NULL) {
+        return _PyStatus_NO_MEMORY();
+    }
 #  ifdef Py_STACKREF_CLOSE_DEBUG
     interp->closed_stackrefs_table = _Py_hashtable_new_full(
         _Py_hashtable_hash_ptr,
@@ -702,6 +705,9 @@ init_interpreter(PyInterpreterState *interp,
         NULL,
         &alloc
     );
+    if (interp->closed_stackrefs_table == NULL) {
+        return _PyStatus_NO_MEMORY();
+    }
 #  endif
     _Py_stackref_associate(interp, Py_None, PyStackRef_None);
     _Py_stackref_associate(interp, Py_False, PyStackRef_False);