mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s4:python bindings - handle NULL returns from "loadparm_init_global"
Reviewed-by: Jelmer Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org> Autobuild-Date: Tue Mar 22 19:52:57 CET 2011 on sn-devel-104
This commit is contained in:
parent
5d09acab7e
commit
3940777a14
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user