Skip to content

Commit fd4965d

Browse files
[3.14] gh-151126: Fix a possible crash during the startup with no memory under Py_STACKREF_DEBUG (GH-152478) (#152678)
gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (GH-152478) (cherry picked from commit ecdef17) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 940be2e commit fd4965d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Python/pystate.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,9 @@ init_interpreter(PyInterpreterState *interp,
694694
NULL,
695695
&alloc
696696
);
697+
if (interp->open_stackrefs_table == NULL) {
698+
return _PyStatus_NO_MEMORY();
699+
}
697700
# ifdef Py_STACKREF_CLOSE_DEBUG
698701
interp->closed_stackrefs_table = _Py_hashtable_new_full(
699702
_Py_hashtable_hash_ptr,
@@ -702,6 +705,9 @@ init_interpreter(PyInterpreterState *interp,
702705
NULL,
703706
&alloc
704707
);
708+
if (interp->closed_stackrefs_table == NULL) {
709+
return _PyStatus_NO_MEMORY();
710+
}
705711
# endif
706712
_Py_stackref_associate(interp, Py_None, PyStackRef_None);
707713
_Py_stackref_associate(interp, Py_False, PyStackRef_False);

0 commit comments

Comments
 (0)