From 2f5e9903a0fa693670cded538dd42088cb2661cf Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Wed, 8 Mar 2006 06:36:45 +0000 Subject: [PATCH] Fix logic error and DECREF reported by Coverity. --- Modules/pyexpat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index b3001eaef75..e4bf180a6ad 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -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) {