Skip to content

Commit a296353

Browse files
sobolevnmiss-islington
authored andcommitted
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 eebdbfd commit a296353

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
@@ -655,6 +655,9 @@ init_interpreter(PyInterpreterState *interp,
655655
NULL,
656656
&alloc
657657
);
658+
if (interp->open_stackrefs_table == NULL) {
659+
return _PyStatus_NO_MEMORY();
660+
}
658661
# ifdef Py_STACKREF_CLOSE_DEBUG
659662
interp->closed_stackrefs_table = _Py_hashtable_new_full(
660663
_Py_hashtable_hash_ptr,
@@ -663,6 +666,9 @@ init_interpreter(PyInterpreterState *interp,
663666
NULL,
664667
&alloc
665668
);
669+
if (interp->closed_stackrefs_table == NULL) {
670+
return _PyStatus_NO_MEMORY();
671+
}
666672
# endif
667673
_Py_stackref_associate(interp, Py_None, PyStackRef_None);
668674
_Py_stackref_associate(interp, Py_False, PyStackRef_False);

0 commit comments

Comments
 (0)