summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_spoolss_forms_conv.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/source3/python/py_spoolss_forms_conv.c b/source3/python/py_spoolss_forms_conv.c
index 6ef953cbc9..cfeb475b1e 100644
--- a/source3/python/py_spoolss_forms_conv.c
+++ b/source3/python/py_spoolss_forms_conv.c
@@ -57,23 +57,30 @@ BOOL py_to_FORM(FORM *form, PyObject *dict)
{
PyObject *obj, *dict_copy = PyDict_Copy(dict);
char *name;
+ BOOL result = False;
- obj = PyDict_GetItemString(dict, "name");
+ if (!(obj = PyDict_GetItemString(dict_copy, "name")) ||
+ !PyString_Check(obj))
+ goto done;
- if (!obj || !PyString_Check(obj))
- return False;
+ PyDict_DelItemString(dict_copy, "name");
+
+ if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
+ !PyInt_Check(obj))
+ goto done;
PyDict_DelItemString(dict_copy, "level");
- PyDict_DelItemString(dict_copy, "name");
- if (!to_struct(form, dict_copy, py_FORM)) {
- Py_DECREF(dict_copy);
- return False;
- }
+ if (!to_struct(form, dict_copy, py_FORM))
+ goto done;
name = PyString_AsString(obj);
init_unistr2(&form->name, name, strlen(name) + 1);
- return True;
+ result = True;
+
+done:
+ Py_DECREF(dict_copy);
+ return result;
}