From 1053b53b575351f677535e98670290c819007e76 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 6 Jul 2026 15:31:12 +0800 Subject: [PATCH] fix copilot false report --- libs/clipboard/src/windows/wf_cliprdr.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/clipboard/src/windows/wf_cliprdr.c b/libs/clipboard/src/windows/wf_cliprdr.c index 04a61f75a..06d62731d 100644 --- a/libs/clipboard/src/windows/wf_cliprdr.c +++ b/libs/clipboard/src/windows/wf_cliprdr.c @@ -3322,6 +3322,13 @@ wf_cliprdr_server_file_contents_response(CliprdrClientContext *context, } clipboard->req_fsize = fileContentsResponse->cbRequested; + /* + * Keep the zero-size allocation: supported Windows builds use the Microsoft + * CRT, where malloc(0) returns a valid pointer. wait_response_event() also + * uses a non-NULL req_fdata to recognize a successful zero-byte response. + * The Rust FFI derives requestedData and cbRequested from the same Vec, so a + * nonzero length cannot have a NULL data pointer on the normal call path. + */ clipboard->req_fdata = (char *)malloc(fileContentsResponse->cbRequested); if (!clipboard->req_fdata) {