mirror of
https://github.com/python/cpython.git
synced 2024-11-24 18:34:43 +08:00
Fix logic error and DECREF reported by Coverity.
This commit is contained in:
parent
025f14b72d
commit
2f5e9903a0
@ -106,8 +106,8 @@ set_error_attr(PyObject *err, char *name, int value)
|
||||
{
|
||||
PyObject *v = PyInt_FromLong(value);
|
||||
|
||||
if (v != NULL && PyObject_SetAttrString(err, name, v) == -1) {
|
||||
Py_DECREF(v);
|
||||
if (v == NULL || PyObject_SetAttrString(err, name, v) == -1) {
|
||||
Py_XDECREF(v);
|
||||
return 0;
|
||||
}
|
||||
Py_DECREF(v);
|
||||
@ -137,7 +137,7 @@ set_error(xmlparseobject *self, enum XML_Error code)
|
||||
&& set_error_attr(err, "lineno", lineno)) {
|
||||
PyErr_SetObject(ErrorObject, err);
|
||||
}
|
||||
Py_DECREF(err);
|
||||
Py_XDECREF(err);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -994,7 +994,7 @@ xmlparse_ParseFile(xmlparseobject *self, PyObject *args)
|
||||
if (PyFile_Check(f)) {
|
||||
fp = PyFile_AsFile(f);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
fp = NULL;
|
||||
readmethod = PyObject_GetAttrString(f, "read");
|
||||
if (readmethod == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user