s4/py_dsdb: catch/handle alloc failures in py_dsdb_normalise_attributes()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 2 May 2018 21:47:18 +0000 (09:47 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 19 Jan 2019 18:21:20 +0000 (19:21 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/pydsdb.c

index 297943b1a5420611961605b94df60c11c72f7b17..3a1e97cf47f32f11b203429f3387de4f928f6c4b 100644 (file)
@@ -744,10 +744,17 @@ static PyObject *py_dsdb_normalise_attributes(PyObject *self, PyObject *args)
                return NULL;
        }
        py_ret = py_type->tp_alloc(py_type, 0);
+       if (py_ret == NULL) {
+               Py_DECREF(py_type);
+               PyErr_NoMemory();
+               return NULL;
+       }
        ret = (PyLdbMessageElementObject *)py_ret;
 
        ret->mem_ctx = talloc_new(NULL);
        if (talloc_reference(ret->mem_ctx, new_el) == NULL) {
+               Py_DECREF(py_type);
+               Py_DECREF(py_ret);
                PyErr_NoMemory();
                return NULL;
        }