VirtualBox

Changeset 76955 in vbox


Ignore:
Timestamp:
Jan 23, 2019 4:27:57 PM (6 years ago)
Author:
vboxsync
Message:

Guest Control/service: A bit of try/catch cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r76553 r76955  
    973973     */
    974974    ClientState *pClient;
    975     //try - can't currently throw anything.
     975    try
    976976    {
    977977        pClient = new (pvClient) ClientState(pThis->mpHelpers, idClient);
    978     }
    979     //catch (std::bad_alloc &)
    980     //{
    981     //    return VERR_NO_MEMORY;
    982     //}
    983     try
    984     {
    985978        pThis->m_ClientStateMap[idClient] = pClient;
    986979    }
    987980    catch (std::bad_alloc &)
    988981    {
    989         pClient->~ClientState();
     982        if (pClient)
     983            pClient->~ClientState();
    990984        return VERR_NO_MEMORY;
    991985    }
     
    21352129    {
    21362130        VBOXGUESTCTRLHOSTCALLBACK data(cParms, paParms);
    2137         /** @todo Not sure if this try/catch is necessary, I pushed it down here from
    2138          * GstCtrlService::call where it was not needed for anything else that I
    2139          * could spot.  I know this might be a tough, but I expect someone writing
    2140          * this kind of code to know what can throw errors and handle them where it
    2141          * is appropriate, rather than grand catch-all-at-the-top crap like this.
    2142          * The reason why it is utter crap, is that you have no state cleanup code
    2143          * where you might need it, which is why I despise exceptions in general */
    2144         try
    2145         {
    2146             rc = mpfnHostCallback(mpvHostData, idFunction, &data, sizeof(data));
    2147         }
    2148         catch (std::bad_alloc &)
    2149         {
    2150             rc = VERR_NO_MEMORY;
    2151         }
     2131        rc = mpfnHostCallback(mpvHostData, idFunction, &data, sizeof(data));
    21522132    }
    21532133    else
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