VirtualBox

Changeset 56567 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 20, 2015 5:15:56 PM (10 years ago)
Author:
vboxsync
Message:

IMachineDebugger: Fixed getters for LogDbgFlags, LogRelFlags, LogDbgGroups, LogRelGroups, LogDbgDestinations and LogRelDestinations. They returned nothing as the i_logStringProps worker method didn't actually have an output parameter and was using a local BSTR variable instead, which it would leak.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MachineDebuggerImpl.h

    r55885 r56567  
    138138    /** Function pointer.  */
    139139    typedef FNLOGGETSTR *PFNLOGGETSTR;
    140     HRESULT i_logStringProps(PRTLOGGER pLogger, PFNLOGGETSTR pfnLogGetStr, const char *pszLogGetStr, Utf8Str aSettings);
     140    HRESULT i_logStringProps(PRTLOGGER pLogger, PFNLOGGETSTR pfnLogGetStr, const char *pszLogGetStr, Utf8Str *pstrSettings);
    141141
    142142    Console * const mParent;
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r55996 r56567  
    455455
    456456HRESULT MachineDebugger::i_logStringProps(PRTLOGGER pLogger, PFNLOGGETSTR pfnLogGetStr,
    457                                           const char *pszLogGetStr, Utf8Str astrSettings)
    458 {
    459     BSTR *a_pbstrSettings = new BSTR;
    460     astrSettings.cloneTo(a_pbstrSettings);
    461 
     457                                          const char *pszLogGetStr, Utf8Str *pstrSettings)
     458{
    462459    /* Make sure the VM is powered up. */
    463460    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     
    470467    if (!pLogger)
    471468    {
    472         Bstr bstrEmpty;
    473         bstrEmpty.cloneTo(a_pbstrSettings);
     469        *pstrSettings = "";
    474470        return S_OK;
    475471    }
     
    481477        char *pszBuf = (char *)RTMemTmpAlloc(cbBuf);
    482478        AssertReturn(pszBuf, E_OUTOFMEMORY);
    483 
    484         int rc = pfnLogGetStr(pLogger, pszBuf, cbBuf);
    485         if (RT_SUCCESS(rc))
    486         {
    487             try
    488             {
    489                 Bstr bstrRet(pszBuf);
    490                 bstrRet.detachTo(a_pbstrSettings);
    491                 hrc = S_OK;
    492             }
    493             catch (std::bad_alloc)
    494             {
    495                 hrc = E_OUTOFMEMORY;
    496             }
    497             RTMemTmpFree(pszBuf);
    498             return hrc;
    499         }
    500         RTMemTmpFree(pszBuf);
    501         AssertReturn(rc == VERR_BUFFER_OVERFLOW, setError(VBOX_E_IPRT_ERROR, tr("%s returned %Rrc"), pszLogGetStr, rc));
     479        int vrc = pstrSettings->reserveNoThrow(cbBuf);
     480        if (RT_SUCCESS(vrc))
     481        {
     482            vrc = pfnLogGetStr(pLogger, pstrSettings->mutableRaw(), cbBuf);
     483            if (RT_SUCCESS(vrc))
     484            {
     485                pstrSettings->jolt();
     486                return S_OK;
     487            }
     488            *pstrSettings = "";
     489            AssertReturn(vrc == VERR_BUFFER_OVERFLOW, setError(VBOX_E_IPRT_ERROR, tr("%s returned %Rrc"), pszLogGetStr, vrc));
     490        }
     491        else
     492            return E_OUTOFMEMORY;
    502493
    503494        /* try again with a bigger buffer. */
     
    509500HRESULT MachineDebugger::getLogDbgFlags(com::Utf8Str &aLogDbgFlags)
    510501{
    511     HRESULT hrc = i_logStringProps(RTLogGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", aLogDbgFlags);
    512 
    513     return hrc;
     502    return i_logStringProps(RTLogGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", &aLogDbgFlags);
    514503}
    515504
    516505HRESULT MachineDebugger::getLogDbgGroups(com::Utf8Str &aLogDbgGroups)
    517506{
    518     HRESULT hrc = i_logStringProps(RTLogGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", aLogDbgGroups);
    519 
    520     return hrc;
     507    return i_logStringProps(RTLogGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", &aLogDbgGroups);
    521508}
    522509
    523510HRESULT MachineDebugger::getLogDbgDestinations(com::Utf8Str &aLogDbgDestinations)
    524511{
    525     HRESULT hrc = i_logStringProps(RTLogGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", aLogDbgDestinations);
    526     return hrc;
     512    return i_logStringProps(RTLogGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", &aLogDbgDestinations);
    527513}
    528514
    529515HRESULT MachineDebugger::getLogRelFlags(com::Utf8Str &aLogRelFlags)
    530516{
    531     HRESULT hrc = i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", aLogRelFlags);
    532     return hrc;
     517    return i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetFlags, "RTGetFlags", &aLogRelFlags);
    533518}
    534519
    535520HRESULT MachineDebugger::getLogRelGroups(com::Utf8Str &aLogRelGroups)
    536521{
    537     HRESULT hrc = i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", aLogRelGroups);
    538     return hrc;
     522    return i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetGroupSettings, "RTLogGetGroupSettings", &aLogRelGroups);
    539523}
    540524
    541525HRESULT MachineDebugger::getLogRelDestinations(com::Utf8Str &aLogRelDestinations)
    542526{
    543     HRESULT hrc = i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", aLogRelDestinations);
    544     return hrc;
     527    return i_logStringProps(RTLogRelGetDefaultInstance(), RTLogGetDestinations, "RTLogGetDestinations", &aLogRelDestinations);
    545528}
    546529
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