]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:pylibsmb: fix a few (potential) memory leaks
authorStefan Metzmacher <metze@samba.org>
Tue, 13 May 2025 14:55:02 +0000 (16:55 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 19 May 2025 09:11:29 +0000 (09:11 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libsmb/pylibsmb.c

index 7bc16a49fe84951bd9441eda256ca5c1ef09a507..19107f9d7fdab19a075cf0f5a97a920df4096c00 100644 (file)
@@ -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;