]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_...
authorsobolevn <mail@sobolevn.me>
Tue, 30 Jun 2026 11:28:17 +0000 (14:28 +0300)
committerGitHub <noreply@github.com>
Tue, 30 Jun 2026 11:28:17 +0000 (14:28 +0300)
Python/pystate.c

index 29f13e92e0dd1fd33332ae308aa14c3e966099ee..e90642fa882db722710b9c4e60608b1964b1293a 100644 (file)
@@ -656,6 +656,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,
@@ -664,6 +667,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);