Skip to content

Commit 259d8c6

Browse files
prakashsellathuraimiss-islington
authored andcommitted
gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906)
(cherry picked from commit 1ab8862) Co-authored-by: Prakash Sellathurai <prakashsellathurai@gmail.com>
1 parent 21f96ea commit 259d8c6

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

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

Objects/frameobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ frame_back_get_impl(PyFrameObject *self)
11171117
/*[clinic end generated code: output=3a84c22a55a63c79 input=9e528570d0e1f44a]*/
11181118
{
11191119
PyObject *res = (PyObject *)PyFrame_GetBack(self);
1120-
if (res == NULL) {
1120+
if (res == NULL && !PyErr_Occurred()) {
11211121
Py_RETURN_NONE;
11221122
}
11231123
return res;
@@ -2405,6 +2405,9 @@ PyFrame_GetBack(PyFrameObject *frame)
24052405
prev = _PyFrame_GetFirstComplete(prev);
24062406
if (prev) {
24072407
back = _PyFrame_GetFrameObject(prev);
2408+
if (back == NULL) {
2409+
return NULL;
2410+
}
24082411
}
24092412
}
24102413
return (PyFrameObject*)Py_XNewRef(back);

0 commit comments

Comments
 (0)