diff options
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/pyhbac.c | 22 | ||||
-rw-r--r-- | src/python/pysss.c | 10 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/python/pyhbac.c b/src/python/pyhbac.c index e9dce9b01..dd345a6eb 100644 --- a/src/python/pyhbac.c +++ b/src/python/pyhbac.c @@ -139,14 +139,17 @@ sequence_as_string_list(PyObject *seq, const char *paramname) utf_item = get_utf8_string(item, p); if (utf_item == NULL) { + Py_DECREF(item); return NULL; } ret[i] = py_strdup(PyString_AsString(utf_item)); Py_DECREF(utf_item); if (!ret[i]) { + Py_DECREF(item); return NULL; } + Py_DECREF(item); } ret[i] = NULL; @@ -242,10 +245,7 @@ str_concat_sequence(PyObject *seq, const char *delim) if (item == NULL) goto fail; part = PyString_AsString(item); - if (part == NULL) { - Py_DECREF(item); - goto fail; - } + if (part == NULL) goto fail; if (s) { s = py_strcat_realloc(s, delim); @@ -260,7 +260,9 @@ str_concat_sequence(PyObject *seq, const char *delim) } return s; + fail: + Py_XDECREF(item); PyMem_Free(s); return NULL; } @@ -269,11 +271,13 @@ fail: static void set_hbac_exception(PyObject *exc, struct hbac_info *error) { - PyErr_SetObject(exc, - Py_BuildValue(sss_py_const_p(char, "(i,s)"), - error->code, - error->rule_name ? \ - error->rule_name : "no rule")); + PyObject *obj; + + obj = Py_BuildValue(sss_py_const_p(char, "(i,s)"), error->code, + error->rule_name ? error->rule_name : "no rule"); + + PyErr_SetObject(exc, obj); + Py_XDECREF(obj); } /* ==================== HBAC Rule Element ========================*/ diff --git a/src/python/pysss.c b/src/python/pysss.c index 8f98f081c..9e899f139 100644 --- a/src/python/pysss.c +++ b/src/python/pysss.c @@ -850,7 +850,7 @@ static PyObject *PySssLocalObject_new(PyTypeObject *type, if (confdb_path == NULL) { talloc_free(mem_ctx); PyErr_NoMemory(); - return NULL; + goto fail; } /* Connect to the conf db */ @@ -859,7 +859,7 @@ static PyObject *PySssLocalObject_new(PyTypeObject *type, talloc_free(mem_ctx); PyErr_SetSssErrorWithMessage(ret, "Could not initialize connection to the confdb\n"); - return NULL; + goto fail; } ret = sssd_domain_init(self->mem_ctx, self->confdb, "local", @@ -868,7 +868,7 @@ static PyObject *PySssLocalObject_new(PyTypeObject *type, talloc_free(mem_ctx); PyErr_SetSssErrorWithMessage(ret, "Could not initialize connection to the sysdb\n"); - return NULL; + goto fail; } self->sysdb = self->local->sysdb; @@ -876,6 +876,10 @@ static PyObject *PySssLocalObject_new(PyTypeObject *type, self->unlock = DO_UNLOCK; return (PyObject *) self; + +fail: + Py_DECREF(self); + return NULL; } /* |