Skip to content

Commit a8e5fed

Browse files
authored
gh-118613: Fix error handling of _PyEval_GetFrameLocals in ceval.c (#118614)
1 parent 1506d5a commit a8e5fed

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Python/ceval.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -2496,17 +2496,21 @@ _PyEval_GetFrameLocals(void)
24962496

24972497
if (PyFrameLocalsProxy_Check(locals)) {
24982498
PyObject* ret = PyDict_New();
2499-
if (PyDict_Update(ret, locals)) {
2499+
if (ret == NULL) {
2500+
Py_DECREF(locals);
2501+
return NULL;
2502+
}
2503+
if (PyDict_Update(ret, locals) < 0) {
25002504
Py_DECREF(ret);
2505+
Py_DECREF(locals);
25012506
return NULL;
25022507
}
25032508
Py_DECREF(locals);
25042509
return ret;
2505-
} else if (PyMapping_Check(locals)) {
2506-
return locals;
25072510
}
25082511

2509-
return NULL;
2512+
assert(PyMapping_Check(locals));
2513+
return locals;
25102514
}
25112515

25122516
PyObject *

0 commit comments

Comments
 (0)