bpo-35454: Fix miscellaneous minor issues in error handling. (#11077)
* bpo-35454: Fix miscellaneous minor issues in error handling.
* Fix a null pointer dereference.
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 62374d8..12e418d 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -352,7 +352,10 @@
return NULL;
}
attrib = PyDict_Copy(attrib);
- PyDict_DelItem(kwds, attrib_str);
+ if (attrib && PyDict_DelItem(kwds, attrib_str) < 0) {
+ Py_DECREF(attrib);
+ attrib = NULL;
+ }
} else {
attrib = PyDict_New();
}