bpo-35454: Fix miscellaneous minor issues in error handling. (GH-11077)
* bpo-35454: Fix miscellaneous minor issues in error handling.
* Fix a null pointer dereference.
(cherry picked from commit 8905fcc85a6fc3ac394bc89b0bbf40897e9497a6)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Python/ceval.c b/Python/ceval.c
index e371d34..00b2e6d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -5027,7 +5027,7 @@
PyObject *names = f->f_code->co_names;
PyObject *name = GETITEM(names, oparg);
PyObject *locals = f->f_locals;
- if (PyDict_CheckExact(locals) &&
+ if (locals && PyDict_CheckExact(locals) &&
PyDict_GetItem(locals, name) == v) {
if (PyDict_DelItem(locals, name) != 0) {
PyErr_Clear();