VirtualBox

Changeset 28316 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 14, 2010 6:01:39 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60075
Message:

com/string.h,Main: Removed Utf8Str::asOutParam() as it mixed allocators - COM/XPCOM allocates the returned param, while RTMemFree is used to free it -> bang.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/VirtualBoxErrorInfoImpl.cpp

    r25149 r28316  
    8282}
    8383
    84 #if !defined (VBOX_WITH_XPCOM)
     84#if !defined(VBOX_WITH_XPCOM)
    8585
    8686/**
     
    141141}
    142142
    143 #else // !defined (VBOX_WITH_XPCOM)
     143#else // defined(VBOX_WITH_XPCOM)
    144144
    145145/**
     
    147147 *  object.
    148148 */
    149 HRESULT VirtualBoxErrorInfo::init (nsIException *aInfo)
     149HRESULT VirtualBoxErrorInfo::init(nsIException *aInfo)
    150150{
    151151    AssertReturn(aInfo, E_FAIL);
     
    157157     * corresponding fields will simply remain null in this case). */
    158158
    159     rc = aInfo->GetResult (&mResultCode);
    160     AssertComRC (rc);
    161     Utf8Str message;
    162     rc = aInfo->GetMessage(message.asOutParam());
    163     message.jolt();
    164     AssertComRC (rc);
    165     mText = message;
     159    rc = aInfo->GetResult(&mResultCode);
     160    AssertComRC(rc);
     161
     162    char *pszMsg;             /* No Utf8Str.asOutParam, different allocator! */
     163    rc = aInfo->GetMessage(&pszMsg);
     164    AssertComRC(rc);
     165    if (NS_SUCCEEDED(rc))
     166    {
     167        mText = Bstr(pszMsg);
     168        nsMemory::Free(pszMsg);
     169    }
     170    else
     171        mText.setNull();
    166172
    167173    return S_OK;
     
    247253                               nsIException, IVirtualBoxErrorInfo)
    248254
    249 #endif // !defined (VBOX_WITH_XPCOM)
     255#endif // defined(VBOX_WITH_XPCOM)
    250256/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

    r26603 r28316  
    8888    }
    8989
    90 #else // !defined (VBOX_WITH_XPCOM)
    91 
    92     nsCOMPtr <nsIExceptionService> es;
    93     es = do_GetService (NS_EXCEPTIONSERVICE_CONTRACTID, &rc);
     90#else // defined (VBOX_WITH_XPCOM)
     91
     92    nsCOMPtr<nsIExceptionService> es;
     93    es = do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID, &rc);
    9494    if (NS_SUCCEEDED(rc))
    9595    {
    96         nsCOMPtr <nsIExceptionManager> em;
    97         rc = es->GetCurrentExceptionManager (getter_AddRefs (em));
     96        nsCOMPtr<nsIExceptionManager> em;
     97        rc = es->GetCurrentExceptionManager(getter_AddRefs (em));
    9898        if (NS_SUCCEEDED(rc))
    9999        {
    100100            ComPtr<nsIException> ex;
    101             rc = em->GetCurrentException (ex.asOutParam());
     101            rc = em->GetCurrentException(ex.asOutParam());
    102102            if (NS_SUCCEEDED(rc) && ex)
    103103            {
     
    114114                    bool gotSomething = false;
    115115
    116                     rc = ex->GetResult (&mResultCode);
     116                    rc = ex->GetResult(&mResultCode);
    117117                    gotSomething |= NS_SUCCEEDED(rc);
    118118
    119                     Utf8Str message;
    120                     rc = ex->GetMessage(message.asOutParam());
    121                     message.jolt();
     119                    char *pszMsg;
     120                    rc = ex->GetMessage(&pszMsg);
    122121                    gotSomething |= NS_SUCCEEDED(rc);
    123122                    if (NS_SUCCEEDED(rc))
    124                         mText = message;
     123                    {
     124                        mText = Bstr(pszMsg);
     125                        nsMemory::Free(mText);
     126                    }
    125127
    126128                    if (gotSomething)
     
    140142    AssertComRC (rc);
    141143
    142 #endif // !defined (VBOX_WITH_XPCOM)
     144#endif // defined (VBOX_WITH_XPCOM)
    143145}
    144146
  • trunk/src/VBox/Main/glue/VirtualBoxErrorInfo.cpp

    r26753 r28316  
    107107}
    108108
    109 #if !defined (VBOX_WITH_XPCOM)
     109#if !defined(VBOX_WITH_XPCOM)
    110110
    111111/**
     
    166166}
    167167
    168 #else // !defined (VBOX_WITH_XPCOM)
     168#else // !defined(VBOX_WITH_XPCOM)
    169169
    170170/**
     
    172172 *  object.
    173173 */
    174 HRESULT VirtualBoxErrorInfo::init (nsIException *aInfo)
     174HRESULT VirtualBoxErrorInfo::init(nsIException *aInfo)
    175175{
    176176    AssertReturn(aInfo, E_FAIL);
     
    182182     * corresponding fields will simply remain null in this case). */
    183183
    184     rc = aInfo->GetResult (&mResultCode);
    185     AssertComRC (rc);
    186     Utf8Str message;
    187     rc = aInfo->GetMessage(message.asOutParam());
    188     message.jolt();
    189     AssertComRC (rc);
    190     mText = message;
     184    rc = aInfo->GetResult(&mResultCode);
     185    AssertComRC(rc);
     186
     187    char *pszMsg;
     188    rc = aInfo->GetMessage(&pszMsg);
     189    AssertComRC(rc);
     190    if (NS_SUCCEEDED(rc))
     191    {
     192        mText = Bstr(pszMsg);
     193        nsMemory::Free(pszMsg);
     194    }
     195    else
     196        mText.setNull();
    191197
    192198    return S_OK;
     
    273279                               nsIException, IVirtualBoxErrorInfo)
    274280
    275 #endif /* !defined (VBOX_WITH_XPCOM) */
     281#endif /* !defined(VBOX_WITH_XPCOM) */
    276282
    277283////////////////////////////////////////////////////////////////////////////////
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