param/pyparam: Cope with string list parameters being empty.
authorRicardo Jorge <rvelhote@gmail.com>
Mon, 3 Aug 2009 22:03:04 +0000 (00:03 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 3 Aug 2009 22:18:43 +0000 (00:18 +0200)
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
source4/param/pyparam.c

index 37e882e1cc876433aa1e1b89902341f320c6807e..58799f8d37f15c7eaae4257563a53298fd713fce 100644 (file)
@@ -129,7 +129,13 @@ static PyObject *py_lp_ctx_get_helper(struct loadparm_context *lp_ctx, const cha
        {
            int j;
            const char **strlist = *(const char ***)parm_ptr;
-           PyObject *pylist = PyList_New(str_list_length(strlist));
+           PyObject *pylist;
+               
+               if(strlist == NULL) {
+                       return PyList_New(0);
+               }
+               
+               pylist = PyList_New(str_list_length(strlist));
            for (j = 0; strlist[j]; j++) 
                PyList_SetItem(pylist, j, 
                               PyString_FromString(strlist[j]));