Skip to content

Commit 117b76a

Browse files
[3.13] gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906) (#152065)
[3.13] gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906) Signed-off-by: Prakash Sellathurai <prakashsellathurai@gmail.com>
1 parent aaf850f commit 117b76a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions
2+
instead of masking them as None.

Objects/frameobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ static PyObject *
963963
frame_getback(PyFrameObject *f, void *closure)
964964
{
965965
PyObject *res = (PyObject *)PyFrame_GetBack(f);
966-
if (res == NULL) {
966+
if (res == NULL && !PyErr_Occurred()) {
967967
Py_RETURN_NONE;
968968
}
969969
return res;
@@ -2203,6 +2203,9 @@ PyFrame_GetBack(PyFrameObject *frame)
22032203
prev = _PyFrame_GetFirstComplete(prev);
22042204
if (prev) {
22052205
back = _PyFrame_GetFrameObject(prev);
2206+
if (back == NULL) {
2207+
return NULL;
2208+
}
22062209
}
22072210
}
22082211
return (PyFrameObject*)Py_XNewRef(back);

0 commit comments

Comments
 (0)