From: Stefan Metzmacher Date: Tue, 13 May 2025 14:55:02 +0000 (+0200) Subject: s3:pylibsmb: fix a few (potential) memory leaks X-Git-Tag: tevent-0.17.0~156 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9076ad2a9f686beedaa77cae1830ed1fca026be4;p=thirdparty%2Fsamba.git s3:pylibsmb: fix a few (potential) memory leaks Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 7bc16a49fe8..19107f9d7fd 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -1677,6 +1677,7 @@ static PyObject *py_smb_savefile(struct py_cli_state *self, PyObject *args) return NULL; } status = cli_close_recv(req); + TALLOC_FREE(req); if (!NT_STATUS_IS_OK(status)) { PyErr_SetNTSTATUS(status); return NULL; @@ -2026,6 +2027,11 @@ static PyObject *py_cli_notify(struct py_cli_state *self, flush_req = tevent_queue_wait_send(req, self->ev, send_queue); + if (flush_req == NULL) { + TALLOC_FREE(req); + PyErr_NoMemory(); + return NULL; + } endtime = timeval_current_ofs_msec(self->cli->timeout); ok = tevent_req_set_endtime(flush_req, self->ev, @@ -2374,7 +2380,8 @@ static NTSTATUS do_listing(struct py_cli_state *self, tevent_req_set_callback(req, do_listing_cb, &state); if (!py_tevent_req_wait_exc(self, req)) { - return NT_STATUS_INTERNAL_ERROR; + status = NT_STATUS_INTERNAL_ERROR; + goto done; } TALLOC_FREE(req); @@ -2385,6 +2392,7 @@ static NTSTATUS do_listing(struct py_cli_state *self, done: TALLOC_FREE(mask); + TALLOC_FREE(req); return status; } @@ -2691,6 +2699,7 @@ static PyObject *py_smb_get_sd(struct py_cli_state *self, PyObject *args) return NULL; } status = cli_query_security_descriptor_recv(req, NULL, &sd); + TALLOC_FREE(req); if (!NT_STATUS_IS_OK(status)) { PyErr_SetNTSTATUS(status); return NULL; @@ -2728,6 +2737,7 @@ static PyObject *py_smb_set_sd(struct py_cli_state *self, PyObject *args) } status = cli_set_security_descriptor_recv(req); + TALLOC_FREE(req); if (!NT_STATUS_IS_OK(status)) { PyErr_SetNTSTATUS(status); return NULL;