1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

FIXUP: Improve memory handling on py_net_change_password

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

Autobuild-User(master): Noel Power <npower@samba.org>
Autobuild-Date(master): Thu May 17 14:28:19 CEST 2018 on sn-devel-144
This commit is contained in:
Andrew Bartlett 2018-05-17 06:37:28 +12:00 committed by Noel Power
parent e7144f2e11
commit 83bde8a49c

View File

@ -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;
}