s4/param: treat NULL value passed to dict_insert as error
authorNoel Power <noel.power@suse.com>
Mon, 16 Mar 2020 15:54:00 +0000 (15:54 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Mar 2020 20:46:42 +0000 (20:46 +0000)
insert_dict is used as a convenience to decrement the values to
prevent leaks with orpahaned PyObjects and avoid excessive creation of
temp variables.

        if (!dict_insert(parameters,
                         "rootdn",
                         PyUnicode_FromString(settings->root_dn_str))) {
                status = NT_STATUS_UNSUCCESSFUL;
                goto out;
        }

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/param/provision.c

index 60ce07384f810b3a7bf0ca40155f0ff7eb295165..5cf38c66dd22d6da1f8662c7b3a65bd65fd32ae4 100644 (file)
@@ -35,6 +35,9 @@ static bool dict_insert(PyObject* dict,
                        const char* key,
                        PyObject* value)
 {
+       if (value == NULL) {
+               return false;
+       }
        if (PyDict_SetItemString(dict, key, value) == -1) {
                Py_XDECREF(value);
                return false;