From 0094d306a86db4c84bbbfc4640367cfc42395acb Mon Sep 17 00:00:00 2001 From: fufesou Date: Tue, 20 Jun 2023 00:32:43 +0800 Subject: [PATCH] win, clipboard, fix pointer Signed-off-by: fufesou --- libs/clipboard/src/windows/wf_cliprdr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libs/clipboard/src/windows/wf_cliprdr.c b/libs/clipboard/src/windows/wf_cliprdr.c index a097bbf83..4d0d4532d 100644 --- a/libs/clipboard/src/windows/wf_cliprdr.c +++ b/libs/clipboard/src/windows/wf_cliprdr.c @@ -358,6 +358,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrStream_Read(IStream *This, void *pv, ULO { CopyMemory(pv, clipboard->req_fdata, clipboard->req_fsize); free(clipboard->req_fdata); + clipboard->req_fdata = NULL; } *pcbRead = clipboard->req_fsize; @@ -569,6 +570,7 @@ static CliprdrStream *CliprdrStream_New(UINT32 connID, ULONG index, void *pData, instance->m_lSize.QuadPart = *((LONGLONG *)clipboard->req_fdata); free(clipboard->req_fdata); + clipboard->req_fdata = NULL; } else success = TRUE; @@ -1444,7 +1446,7 @@ static UINT cliprdr_send_format_list(wfClipboard *clipboard, UINT32 connID) return rc; } -UINT wait_response_event(wfClipboard *clipboard, HANDLE event, void *data) +UINT wait_response_event(wfClipboard *clipboard, HANDLE event, void **data) { UINT rc = ERROR_SUCCESS; clipboard->context->IsStopped = FALSE; @@ -1474,7 +1476,7 @@ UINT wait_response_event(wfClipboard *clipboard, HANDLE event, void *data) rc = ERROR_INTERNAL_ERROR; } - if (data == NULL) + if ((*data) == NULL) { rc = ERROR_INTERNAL_ERROR; } @@ -1482,7 +1484,7 @@ UINT wait_response_event(wfClipboard *clipboard, HANDLE event, void *data) return rc; } - if (data != NULL) + if ((*data) != NULL) { if (!ResetEvent(event)) { @@ -1514,7 +1516,7 @@ static UINT cliprdr_send_data_request(UINT32 connID, wfClipboard *clipboard, UIN return rc; } - wait_response_event(clipboard, clipboard->response_data_event, clipboard->hmem); + wait_response_event(clipboard, clipboard->response_data_event, &clipboard->hmem); } UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 connID, const void *streamid, ULONG index, @@ -1542,7 +1544,7 @@ UINT cliprdr_send_request_filecontents(wfClipboard *clipboard, UINT32 connID, co return rc; } - return wait_response_event(clipboard, clipboard->req_fevent, clipboard->req_fdata); + return wait_response_event(clipboard, clipboard->req_fevent, (void**)&clipboard->req_fdata); } static UINT cliprdr_send_response_filecontents(