VirtualBox

Changeset 103240 in vbox for trunk/src


Ignore:
Timestamp:
Feb 7, 2024 11:21:56 AM (15 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161526
Message:

Shared Clipboard/X11: Only allocate SHCLX11RESPONSE as event payload in clipConvertDataFromX11Worker() if we actually have data to send back. Should fix some leaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r102929 r103240  
    23832383                pReq->Read.idxFmtX11, pReq->Read.uFmtVBox, rc));
    23842384
    2385     int rc2;
    2386 
    23872385    PSHCLEVENTPAYLOAD pPayload = NULL;
    2388     size_t            cbResp   = sizeof(SHCLX11RESPONSE);
    2389     PSHCLX11RESPONSE  pResp    = (PSHCLX11RESPONSE)RTMemAllocZ(cbResp);
    2390     if (pResp)
    2391     {
    2392         pResp->enmType     = SHCLX11EVENTTYPE_READ;
    2393         pResp->Read.pvData = pvDst;
    2394         pResp->Read.cbData = cbDst;
    2395 
    2396         pvDst = NULL; /* The response owns the data now. */
    2397 
    2398         if (   pResp->Read.pvData
    2399             && pResp->Read.cbData)
    2400         {
    2401             rc2 = ShClPayloadInit(0 /* ID, unused */, pResp, cbResp, &pPayload);
    2402             AssertRC(rc2);
    2403         }
    2404     }
    2405     else
    2406         rc = VERR_NO_MEMORY;
    2407 
    2408     rc2 = ShClEventSignal(pReq->pEvent, pPayload);
     2386
     2387    if (   pvDst
     2388        && cbDst)
     2389    {
     2390        size_t           cbResp   = sizeof(SHCLX11RESPONSE);
     2391        PSHCLX11RESPONSE pResp    = (PSHCLX11RESPONSE)RTMemAllocZ(cbResp);
     2392        if (pResp)
     2393        {
     2394            pResp->enmType     = SHCLX11EVENTTYPE_READ;
     2395            pResp->Read.pvData = pvDst;
     2396            pResp->Read.cbData = cbDst;
     2397
     2398            pvDst = NULL; /* The response owns the data now. */
     2399
     2400            rc = ShClPayloadInit(0 /* ID, unused */, pResp, cbResp, &pPayload);
     2401        }
     2402        else
     2403            rc = VERR_NO_MEMORY;
     2404    }
     2405
     2406    /* Let the caller know in any case. */
     2407    int rc2 = ShClEventSignal(pReq->pEvent, pPayload);
    24092408    if (RT_SUCCESS(rc2))
    24102409        pPayload = NULL; /* The event owns the payload now. */
     2410
     2411    if (RT_SUCCESS(rc))
     2412        rc = rc2;
    24112413
    24122414    if (pPayload) /* Free payload on error. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette