diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c index cd05bd7ccf6..5fe37031382 100644 --- a/source4/auth/gensec/pygensec.c +++ b/source4/auth/gensec/pygensec.c @@ -113,6 +113,11 @@ static PyObject *py_gensec_start_client(PyTypeObject *type, PyObject *args, PyOb } settings->lp_ctx = loadparm_init_global(true); + if (settings->lp_ctx == NULL) { + PyErr_NoMemory(); + PyObject_DEL(self); + return NULL; + } } ev = tevent_context_init(self->talloc_ctx); @@ -181,6 +186,11 @@ static PyObject *py_gensec_start_server(PyTypeObject *type, PyObject *args, PyOb } settings->lp_ctx = loadparm_init_global(true); + if (settings->lp_ctx == NULL) { + PyErr_NoMemory(); + PyObject_DEL(self); + return NULL; + } } ev = tevent_context_init(self->talloc_ctx); diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index a248215fd93..3ba81468605 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -335,6 +335,10 @@ static PyObject *py_lp_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwa return NULL; } ret->ptr = loadparm_init_global(false); + if (ret->ptr == NULL) { + PyErr_NoMemory(); + return NULL; + } return (PyObject *)ret; } diff --git a/source4/param/pyparam_util.c b/source4/param/pyparam_util.c index 528c007624d..cbf2095e855 100644 --- a/source4/param/pyparam_util.c +++ b/source4/param/pyparam_util.c @@ -35,6 +35,9 @@ _PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyOb if (PyString_Check(py_obj)) { lp_ctx = loadparm_init_global(false); + if (lp_ctx == NULL) { + return NULL; + } if (!lpcfg_load(lp_ctx, PyString_AsString(py_obj))) { PyErr_Format(PyExc_RuntimeError, "Unable to load %s", PyString_AsString(py_obj));