From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 23 Jun 2026 06:28:59 +0000 (+0200) Subject: [3.15] gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906) (#151919) X-Git-Tag: v3.15.0b3~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe5dc86f1f8a3e2baad924cf0c01e1a4c81858da;p=thirdparty%2FPython%2Fcpython.git [3.15] gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906) (#151919) Co-authored-by: Prakash Sellathurai --- diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst new file mode 100644 index 000000000000..c71122df6b85 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst @@ -0,0 +1 @@ +Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions instead of masking them as None. diff --git a/Objects/frameobject.c b/Objects/frameobject.c index f60cdb2dd1bf..3e70a7195370 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -1117,7 +1117,7 @@ frame_back_get_impl(PyFrameObject *self) /*[clinic end generated code: output=3a84c22a55a63c79 input=9e528570d0e1f44a]*/ { PyObject *res = (PyObject *)PyFrame_GetBack(self); - if (res == NULL) { + if (res == NULL && !PyErr_Occurred()) { Py_RETURN_NONE; } return res; @@ -2405,6 +2405,9 @@ PyFrame_GetBack(PyFrameObject *frame) prev = _PyFrame_GetFirstComplete(prev); if (prev) { back = _PyFrame_GetFrameObject(prev); + if (back == NULL) { + return NULL; + } } } return (PyFrameObject*)Py_XNewRef(back);