From 3940777a14a93dbf88fcc9e43452fc2f84a7b6fc Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Mon, 21 Mar 2011 10:32:24 +0100 Subject: s4:python bindings - handle NULL returns from "loadparm_init_global" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jelmer Autobuild-User: Matthias Dieter Wallnöfer Autobuild-Date: Tue Mar 22 19:52:57 CET 2011 on sn-devel-104 --- source4/param/pyparam.c | 4 ++++ source4/param/pyparam_util.c | 3 +++ 2 files changed, 7 insertions(+) (limited to 'source4/param') diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index a248215fd9..3ba8146860 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 528c007624..cbf2095e85 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)); -- cgit