From: Andrew Bartlett Date: Wed, 16 May 2018 18:37:28 +0000 (+1200) Subject: FIXUP: Improve memory handling on py_net_change_password X-Git-Tag: ldb-1.4.0~139 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83bde8a49cf3015c71302fbd209f95006e7535b2;p=thirdparty%2Fsamba.git FIXUP: Improve memory handling on py_net_change_password Signed-off-by: Andrew Bartlett Reviewed-by: Noel Power Autobuild-User(master): Noel Power Autobuild-Date(master): Thu May 17 14:28:19 CEST 2018 on sn-devel-144 --- diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index 6aff373b359..65060d53091 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -195,22 +195,27 @@ static PyObject *py_net_change_password(py_net_Object *self, PyObject *args, PyO mem_ctx = talloc_new(ev); if (mem_ctx == NULL) { + PyMem_Free(discard_const_p(char, newpass)); + PyMem_Free(discard_const_p(char, oldpass)); PyErr_NoMemory(); return NULL; } status = libnet_ChangePassword(self->libnet_ctx, mem_ctx, &r); + + PyMem_Free(discard_const_p(char, newpass)); + PyMem_Free(discard_const_p(char, oldpass)); + if (NT_STATUS_IS_ERR(status)) { PyErr_SetNTSTATUS_and_string(status, r.generic.out.error_string ? r.generic.out.error_string : nt_errstr(status)); + talloc_free(mem_ctx); return NULL; } talloc_free(mem_ctx); - PyMem_Free(discard_const_p(char,newpass)); - PyMem_Free(discard_const_p(char,oldpass)); Py_RETURN_NONE; }