]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906) (#152065)
authorPrakash Sellathurai <prakashsellathurai@gmail.com>
Wed, 24 Jun 2026 11:40:07 +0000 (17:10 +0530)
committerGitHub <noreply@github.com>
Wed, 24 Jun 2026 11:40:07 +0000 (11:40 +0000)
[3.13] gh-151905: fix memory error handling in PyFrame_GetBack
(pythonGH-151906)

Signed-off-by: Prakash Sellathurai <prakashsellathurai@gmail.com>
Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst [new file with mode: 0644]
Objects/frameobject.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst
new file mode 100644 (file)
index 0000000..c021452
--- /dev/null
@@ -0,0 +1,2 @@
+Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions
+instead of masking them as None.
index 467c3fe56e98f206423d2e150f7319286d24f42f..9d26a3cdeed4e7d2d087b3e15bf89e2ff417cb5d 100644 (file)
@@ -963,7 +963,7 @@ static PyObject *
 frame_getback(PyFrameObject *f, void *closure)
 {
     PyObject *res = (PyObject *)PyFrame_GetBack(f);
-    if (res == NULL) {
+    if (res == NULL  && !PyErr_Occurred()) {
         Py_RETURN_NONE;
     }
     return res;
@@ -2203,6 +2203,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);