VirtualBox

Ignore:
Timestamp:
May 25, 2019 8:51:40 PM (6 years ago)
Author:
vboxsync
Message:

Console::powerUp: Another delete NULL on the unlikely chance of catching a bad_alloc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r78750 r78751  
    22242224            if (!pTask->isOk())
    22252225            {
    2226                 hrc = setError(FAILED(hrc) ? hrc : E_FAIL, "Could not create VMPowerDownTask object\n");
     2226                hrc = setError(FAILED(pTask->rc()) ? pTask->rc() : E_FAIL, "Could not create VMPowerDownTask object\n");
    22272227                delete(pTask);
    22282228                pTask = NULL;
     
    76217621    LONG cOperations = 1;
    76227622    LONG ulTotalOperationsWeight = 1;
    7623     VMPowerUpTask* task = NULL;
     7623    VMPowerUpTask *task = NULL;
    76247624
    76257625    try
     
    77407740        /* Setup task object and thread to carry out the operation
    77417741         * asynchronously */
    7742         try
    7743         {
    7744             task = new VMPowerUpTask(this, pPowerupProgress);
    7745             if (!task->isOk())
    7746             {
    7747                 throw E_FAIL;
    7748             }
    7749         }
    7750         catch(...)
    7751         {
    7752             delete task;
    7753             rc = setError(E_FAIL, "Could not create VMPowerUpTask object \n");
    7754             throw rc;
    7755         }
     7742        try { task = new VMPowerUpTask(this, pPowerupProgress); }
     7743        catch (std::bad_alloc &) { throw rc = E_OUTOFMEMORY; }
     7744        if (!task->isOk())
     7745            throw task->rc();
    77567746
    77577747        task->mConfigConstructor = i_configConstructor;
     
    77597749        task->mStartPaused = aPaused;
    77607750        if (mMachineState == MachineState_Saved)
    7761             task->mSavedStateFile = savedStateFile;
     7751            try { task->mSavedStateFile = savedStateFile; }
     7752            catch (std::bad_alloc &) { throw rc = E_OUTOFMEMORY; }
    77627753        task->mTeleporterEnabled = fTeleporterEnabled;
    77637754        task->mEnmFaultToleranceState = enmFaultToleranceState;
     
    79017892            AssertComRCReturnRC(rc);
    79027893        }
    7903         else if (    mMachineState == MachineState_Saved
    7904             || (!fTeleporterEnabled && !fFaultToleranceSyncEnabled))
     7894        else if (   mMachineState == MachineState_Saved
     7895                 || (!fTeleporterEnabled && !fFaultToleranceSyncEnabled))
    79057896        {
    79067897            rc = pPowerupProgress->init(static_cast<IConsole *>(this),
     
    80128003        /* setup task object and thread to carry out the operation
    80138004         * asynchronously */
    8014         if (aProgress){
    8015                 rc = pPowerupProgress.queryInterfaceTo(aProgress);
    8016                 AssertComRCReturnRC(rc);
     8005        if (aProgress)
     8006        {
     8007            rc = pPowerupProgress.queryInterfaceTo(aProgress);
     8008            AssertComRCReturnRC(rc);
    80178009        }
    80188010
    80198011        rc = task->createThread();
    8020 
     8012        task = NULL;
    80218013        if (FAILED(rc))
    80228014            throw rc;
     
    80348026            i_setMachineState(MachineState_Starting);
    80358027    }
    8036     catch (HRESULT aRC) { rc = aRC; }
     8028    catch (HRESULT aRC)
     8029    {
     8030        rc = aRC;
     8031    }
    80378032
    80388033    if (FAILED(rc) && fBeganPoweringUp)
     
    80518046        /* signal end of operation */
    80528047        mControl->EndPowerUp(rc);
     8048    }
     8049
     8050    if (task)
     8051    {
     8052        ErrorInfoKeeper eik;
     8053        delete task;
    80538054    }
    80548055
     
    88488849                 * asynchronously (if we call powerDown() right here but there
    88498850                 * is one or more mpUVM callers (added with addVMCaller()) we'll
    8850                  * deadlock).
    8851                  */
    8852                 VMPowerDownTask* task = NULL;
     8851                 * deadlock). */
     8852                VMPowerDownTask *task = NULL;
    88538853                try
    88548854                {
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