https://github.com/python/cpython/commit/a8e5fed1007233f677d3539162257b99b920df00
commit: a8e5fed1007233f677d3539162257b99b920df00
branch: main
author: Nikita Sobolev <m...@sobolevn.me>
committer: sobolevn <m...@sobolevn.me>
date: 2024-05-06T10:34:56+03:00
summary:

gh-118613: Fix error handling of `_PyEval_GetFrameLocals` in `ceval.c` (#118614)

files:
M Python/ceval.c

diff --git a/Python/ceval.c b/Python/ceval.c
index 0d02a9887bef7a..128e0417a9fd63 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2496,17 +2496,21 @@ _PyEval_GetFrameLocals(void)
 
     if (PyFrameLocalsProxy_Check(locals)) {
         PyObject* ret = PyDict_New();
-        if (PyDict_Update(ret, locals)) {
+        if (ret == NULL) {
+            Py_DECREF(locals);
+            return NULL;
+        }
+        if (PyDict_Update(ret, locals) < 0) {
             Py_DECREF(ret);
+            Py_DECREF(locals);
             return NULL;
         }
         Py_DECREF(locals);
         return ret;
-    } else if (PyMapping_Check(locals)) {
-        return locals;
     }
 
-    return NULL;
+    assert(PyMapping_Check(locals));
+    return locals;
 }
 
 PyObject *

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to