VirtualBox

Changeset 100482 in vbox for trunk


Ignore:
Timestamp:
Jul 10, 2023 5:07:44 PM (17 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Don't alloc extra stuff in ShClTransferListEntryAlloc(), this otherwise will leak memory when using ShClTransferListEntryInit[Ex] afterwards. bugref:9437

File:
1 edited

Legend:

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

    r100481 r100482  
    452452int ShClTransferListEntryAlloc(PSHCLLISTENTRY *ppListEntry)
    453453{
    454     PSHCLLISTENTRY pListEntry = (PSHCLLISTENTRY)RTMemAlloc(sizeof(SHCLLISTENTRY));
     454    AssertPtrReturn(ppListEntry, VERR_INVALID_POINTER);
     455
     456    PSHCLLISTENTRY pListEntry = (PSHCLLISTENTRY)RTMemAllocZ(sizeof(SHCLLISTENTRY));
    455457    if (!pListEntry)
    456458        return VERR_NO_MEMORY;
    457459
    458     int rc;
    459 
    460     size_t cbInfo = sizeof(SHCLFSOBJINFO);
    461     void  *pvInfo = RTMemAlloc(cbInfo);
    462     if (pvInfo)
    463     {
    464         rc = ShClTransferListEntryInitEx(pListEntry, VBOX_SHCL_INFO_F_NONE, NULL /* pszName */, pvInfo, (uint32_t)cbInfo);
    465         if (RT_SUCCESS(rc))
    466             *ppListEntry = pListEntry;
    467 
    468         return rc;
    469     }
    470     else
    471         rc = VERR_NO_MEMORY;
    472 
    473     RTMemFree(pListEntry);
    474     return rc;
     460    *ppListEntry = pListEntry;
     461
     462    return VINF_SUCCESS;
    475463}
    476464
Note: See TracChangeset for help on using the changeset viewer.

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