Skip to content

Commit 2f5e990

Browse files
committed
Fix logic error and DECREF reported by Coverity.
1 parent 025f14b commit 2f5e990

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Modules/pyexpat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ set_error_attr(PyObject *err, char *name, int value)
106106
{
107107
PyObject *v = PyInt_FromLong(value);
108108

109-
if (v != NULL && PyObject_SetAttrString(err, name, v) == -1) {
110-
Py_DECREF(v);
109+
if (v == NULL || PyObject_SetAttrString(err, name, v) == -1) {
110+
Py_XDECREF(v);
111111
return 0;
112112
}
113113
Py_DECREF(v);
@@ -137,7 +137,7 @@ set_error(xmlparseobject *self, enum XML_Error code)
137137
&& set_error_attr(err, "lineno", lineno)) {
138138
PyErr_SetObject(ErrorObject, err);
139139
}
140-
Py_DECREF(err);
140+
Py_XDECREF(err);
141141
return NULL;
142142
}
143143

@@ -994,7 +994,7 @@ xmlparse_ParseFile(xmlparseobject *self, PyObject *args)
994994
if (PyFile_Check(f)) {
995995
fp = PyFile_AsFile(f);
996996
}
997-
else{
997+
else {
998998
fp = NULL;
999999
readmethod = PyObject_GetAttrString(f, "read");
10001000
if (readmethod == NULL) {

0 commit comments

Comments
 (0)