VirtualBox

Changeset 98587 in vbox


Ignore:
Timestamp:
Feb 15, 2023 1:23:05 PM (22 months ago)
Author:
vboxsync
Message:

HostServices/TstHGCMMock.cpp: fixed memory leak that upsets the tests in asan builds and documented ownership assumptions surrounding it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/testcase/TstHGCMMock.cpp

    r98578 r98587  
    192192    pFn->u.Call.hCall    = callHandle;
    193193    pFn->u.Call.iFunc    = function;
     194    pFn->u.Call.cParms   = cParms;
    194195    PVBOXHGCMSVCPARM const paParmsCopy = (PVBOXHGCMSVCPARM)RTMemDup(paParms, cbParms);
    195196    pFn->u.Call.pParms   = paParmsCopy;
    196     AssertPtrReturn(pFn->u.Call.pParms, VERR_NO_MEMORY);
    197     pFn->u.Call.cParms   = cParms;
     197    AssertPtrReturn(paParmsCopy, VERR_NO_MEMORY);
    198198
    199199    RTListAppend(&pSvc->lstCall, &pFn->Node);
     200    pFn = NULL; /* Thread takes ownership now. We keep ownership of paParmsCopy. */
    200201
    201202    int rc2 = RTSemEventSignal(pSvc->hEventQueue);
     
    206207
    207208    memcpy(paParms, paParmsCopy, cbParms);
    208     /** @todo  paParmsCopy is leaked, right? Doesn't appear to be a
    209      *         use-after-free here. (pFn is freeded though) */
     209    RTMemFree(paParmsCopy);
    210210
    211211    return VINF_SUCCESS; /** @todo Return host call rc */
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