s4/pyauth: fix memory leak when context_new() has bad arguments
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 24 Apr 2018 00:38:22 +0000 (12:38 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Feb 2019 02:36:17 +0000 (03:36 +0100)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/auth/pyauth.c

index 0736859092c990b5a1aeb14a598939fdb43622c5..861b6983c9c1ebf22c9e12cb8172768fcb9b8efa 100644 (file)
@@ -361,12 +361,14 @@ static PyObject *py_auth_context_new(PyTypeObject *type, PyObject *args, PyObjec
 
        lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
        if (lp_ctx == NULL) {
+               talloc_free(mem_ctx);
                PyErr_NoMemory();
                return NULL;
        }
 
        ev = s4_event_context_init(mem_ctx);
        if (ev == NULL) {
+               talloc_free(mem_ctx);
                PyErr_NoMemory();
                return NULL;
        }