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

This commit is contained in:
Nikita Sobolev 2024-05-06 10:34:56 +03:00 committed by GitHub
parent 1506d5adc4
commit a8e5fed100
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2496,17 +2496,21 @@ _PyEval_GetFrameLocals(void)
if (PyFrameLocalsProxy_Check(locals)) { if (PyFrameLocalsProxy_Check(locals)) {
PyObject* ret = PyDict_New(); 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(ret);
Py_DECREF(locals);
return NULL; return NULL;
} }
Py_DECREF(locals); Py_DECREF(locals);
return ret; return ret;
} else if (PyMapping_Check(locals)) {
return locals;
} }
return NULL; assert(PyMapping_Check(locals));
return locals;
} }
PyObject * PyObject *