From: sobolevn Date: Tue, 30 Jun 2026 11:28:17 +0000 (+0300) Subject: gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecdef1773006529b0fea6639d0effeecbb41679c;p=thirdparty%2FPython%2Fcpython.git gh-151126: Fix a possible crash during the startup with no memory under `Py_STACKREF_DEBUG` (#152478) --- diff --git a/Python/pystate.c b/Python/pystate.c index 29f13e92e0dd..e90642fa882d 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -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);